Part Number Hot Search : 
CMX615P3 D5023 GW20N HV101K6 2SK679A 170M6592 CONTROLS 02770
Product Description
Full Text Search
 

To Download C8051F06007 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  mixed signal isp flash mcu family c8051f060/1/2/3/4/5/6/7 preliminary rev. 1.2 7/04 copyright ? 2004 by silicon laboratories c8051f060/1/2/3/4/5/6/7 this information applies to a product under dev elopment. its characteristics and specifications are s ubject to change without n otice. analog peripherals - two 16-bit sar adcs ? 16-bit resolution ? 0.75 lsb inl, guaranteed no missing codes ? programmable throughput up to 1 msps ? operate as two single-ended or one differential con- verter ? direct memory access; data stored in ram without software overhead ? data-dependent windowed interrupt generator - 10-bit sar adc (c8051f060/1/2/3) ? programmable throughput up to 200 ksps ? 8 external inputs, single-ended or differential ? built-in temperature sensor - two 12-bit dacs (c8051f060/1/2/3) ? can synchronize outputs to timers for jitter-free wave- form generation - three analog comparators ? programmable hysteresis/response time - voltage reference - precision vdd monitor/brown-out detector on-chip jtag debug & boundary scan - on-chip debug circuitry facilitates full-speed, non- intrusive in-circuit/in-system debugging - provides breakpoints, single-stepping, watchpoints, stack monitor; inspect/modi fy memory and registers - superior performance to emulation systems using ice-chips, target pods, and sockets - ieee1149.1 compli ant boundary scan - complete development kit high speed 8051 c core - pipelined instruction architecture; executes 70% of instruction set in 1 or 2 system clocks - up to 25 mips throughput with 25 mhz clock - flexible interrupt sources memory - 4352 bytes internal data ram (4 k + 256) - 64 kb (c8051f060/1/2/3/4/5), 32 kb (c8051f066/7) flash; in-system programm able in 512-byte sectors - external 64 kb data memory interface with multi- plexed and non-multiplexed modes (c8051f060/2/ 4/6) digital peripherals - 59 general purpose i/o pins (c8051f060/2/4/6) - 24 general purpose i/o pins (c8051f061/3/5/7) - bosch controller area network (can 2.0b - c8051f060/1/2/3) - hardware smbus? (i2c? co mpatible), spi?, and two uart serial ports available concurrently - programmable 16-bit coun ter/timer array with 6 capture/compare modules - 5 general purpose 16-bit counter/timers - dedicated watchdog timer; bi-directional reset pin clock sources - internal calibrated precision oscillator: 24.5 mhz - external oscillator: crystal, rc, c, or clock supply voltage .......................... 2.7 to 3.6 v - multiple power saving sleep and shutdown modes 100-pin and 64-pin tqfp packages available temperature range: -40 to +85 c jtag 64/32 kb isp flash 4352 b sram sanity control 16-bit 1 msps adc clock circuit temp sensor analog peripherals port 0 port 1 port 2 crossbar digital i/o high-speed controller core debug circuitry 22 interrupts 8051 cpu (25mips) 10-bit 200ksps adc port 4 port 5 port 6 port 7 external memory interface 100 pin only uart0 smbus spi bus pca timer 0 timer 1 timer 2 timer 3 timer 4 uart1 can 2.0b c8051f060/1/2/3 amux vref dma interface 16-bit 1 msps adc 12-bit dac volt age comparat or s 12-bit dac port 3 + - + - + - c8051f060/1/2/3 only
c8051f060/1/2/3/4/5/6/7 2 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 3 table of contents 1. system overview............ ................ ................ ................. .............. .............. ........... 19 1.1. cip-51? microcontroller core.. ................ ................. .............. .............. ........... 25 1.1.1. fully 8051 compatible...... ................ ................. .............. .............. ........... 25 1.1.2. improved throughput ............ .............. .............. .............. .............. ........... 25 1.1.3. additional features .......... ................ ................. .............. .............. ........... 26 1.2. on-chip memory......... ................ ................. .............. .............. .............. ........... 27 1.3. jtag debug and boundary scan.. .............. .............. .............. .............. ........... 28 1.4. programmable digital i/o and crossbar ............... ................. ................ ........... 29 1.5. programmable counter array ... ................ ................. .............. .............. ........... 30 1.6. controller area network.......... ................ ................ ................. .............. ........... 31 1.7. serial ports ............ ................. ................ ................ ................. .............. ........... 32 1.8. 16-bit analog to digital conver ters.............. .............. .............. .............. ........... 33 1.9. 10-bit analog to digital conver ter.................... .............. ............... ........... ......... 34 1.10.12-bit digital to analog conv erters.............. .............. .............. .............. ........... 35 1.11.analog comparators... ................ ................. .............. .............. .............. ........... 36 2. absolute maximum ratings ........ ................ ................ ................. .............. ........... 37 3. global dc electrical characteristi cs ...................... ................ ................. ............. 38 4. pinout and package definitions..... ............... ................. .............. .............. ........... 39 5. 16-bit adcs (adc0 and adc1) ....... ................. .............. .............. .............. ........... 51 5.1. single-ended or differential operation ............... ................ ................. ............. 52 5.1.1. pseudo-differential inputs .. ................. .............. .............. .............. ........... 52 5.2. voltage reference ...... ................ ................. .............. .............. .............. ........... 53 5.3. adc modes of operation........ ................ ................ ................. .............. ........... 54 5.3.1. starting a conversion....... ................ ................. .............. .............. ........... 54 5.3.2. tracking modes................ ................ ................. .............. .............. ........... 54 5.3.3. settling time r equirements ................ .............. .............. .............. ........... 56 5.4. calibration....... ................. .............. .............. .............. .............. .............. ........... 66 5.5. adc0 programmable window de tector ............... ................. ................ ........... 69 6. direct memory access interfac e (dma0) ............... ................ ................. ............. 75 6.1. writing to the instruction buff er................. ................. .............. .............. ........... 75 6.2. dma0 instruction form at ................... ................. ................ ................. ............. 76 6.3. xram addressing and setup ... ................ ................. .............. .............. ........... 76 6.4. instruction execution in mode 0............ ................ ................. ................ ........... 77 6.5. instruction execution in mode 1............ ................ ................. ................ ........... 78 6.6. interrupt sources ...... ................ ................ ................. .............. .............. ........... 79 6.7. data buffer overflow warni ngs and errors......... ................ ................. ............. 79 7. 10-bit adc (adc 2, c8051f060/1/2/3).......... ................ ................. .............. ........... 87 7.1. analog multiplexer ...... ................ ................. .............. .............. .............. ........... 88 7.2. modes of operation ............. ................. ................ ................. ................ ........... 89 7.2.1. starting a conversion....... ................ ................. .............. .............. ........... 89 7.2.2. tracking modes................ ................ ................. .............. .............. ........... 90 7.2.3. settling time r equirements ................ .............. .............. .............. ........... 91
c8051f060/1/2/3/4/5/6/7 4 rev. 1.2 7.3. programmable window detector ................. .............. .............. .............. ........... 97 7.3.1. window detector in sing le-ended mode .......... .............. .............. ........... 99 7.3.2. window detector in differential mode..... .............. ............... ........... ....... 100 8. dacs, 12-bit voltag e mode (dac0 and dac1, c8051f 060/1/2/3) ......... ........... 103 8.1. dac output scheduling ................. .............. .............. .............. .............. ......... 104 8.1.1. update output on-demand .. .............. .............. .............. .............. ......... 104 8.1.2. update output based on timer overflow ............. ............... ........... ....... 104 8.2. dac output scaling/justificat ion ................. .............. .............. .............. ......... 104 9. voltage reference 2 (c8051f060/2) ................. .............. .............. .............. ......... 111 10. voltage reference 2 (c8051f061/3) ................ .............. .............. .............. ......... 113 11. voltage reference 2 (c8051f064/5/ 6/7) ............. .............. .............. .............. ....... 115 12. comparators ................ ................. ................ ................ ................. .............. ......... 117 12.1.comparator inputs...... ................ ................. .............. .............. .............. ......... 119 13. cip-51 microcontroller .............. ................. ................ ................. ................ ......... 123 13.1.instruction set........... ................ ................ ................. .............. .............. ......... 125 13.1.1.instruction and cpu timing .. .............. .............. .............. .............. ......... 125 13.1.2.movx instruction and pr ogram memory .......... .............. .............. ......... 125 13.2.memory organization ............. ................ ................ ................. .............. ......... 130 13.2.1.program memory .... .............. .............. .............. .............. .............. ......... 130 13.2.2.data memory........ ................. .............. .............. .............. .............. ......... 131 13.2.3.general purpose registers ................. .............. .............. .............. ......... 131 13.2.4.bit addressable locations.. ................. .............. .............. .............. ......... 131 13.2.5.stack ............ ................. ................ ................ ................. .............. ......... 131 13.2.6.special function register s ................. .............. .............. .............. ......... 132 13.2.6.1.sfr paging ...... ................ ................. ................ ................. ........... 132 13.2.6.2.interrupts and sfr pagi ng ................ ................ ................. ........... 132 13.2.6.3.sfr page stack example ................. ................ ................. ........... 134 13.2.7.register description s ................ ................. ................ ................. ........... 148 13.3.interrupt handler....... ................ ................ ................. .............. .............. ......... 151 13.3.1.mcu interrupt sources and vectors ....... .............. ............... ........... ....... 151 13.3.2.external interrupts.......... ................ ................ ................. .............. ......... 151 13.3.3.interrupt priorities........ ................. ................ ................. ................ ......... 153 13.3.4.interrupt latency .............. ................ ................. .............. .............. ......... 153 13.3.5.interrupt register descriptions............ .............. .............. .............. ......... 154 13.4.power management modes........ ................. .............. .............. .............. ......... 160 13.4.1.idle mode ........... ................ ................. .............. .............. .............. ......... 160 13.4.2.stop mode............ ................. .............. .............. .............. .............. ......... 161 14. reset sources.......... ................ ................ ................. ................ ................. ........... 163 14.1.power-on reset........ ................ ................ ................. .............. .............. ......... 164 14.2.power-fail reset ....... ................ ................ ................. .............. .............. ......... 164 14.3.external reset .......... ................ ................ ................. .............. .............. ......... 164 14.4.missing clock detector reset ... ............... ................. .............. .............. ......... 165 14.5.comparator0 reset ............. ................. ................ ................. ................ ......... 165 14.6.external cnvstr2 pin reset ... ............... ................. .............. .............. ......... 165 14.7.watchdog timer reset.... .............. .............. .............. .............. .............. ......... 165
c8051f060/1/2/3/4/5/6/7 rev. 1.2 5 14.7.1.enable/reset wdt ............ ................. .............. .............. .............. ......... 166 14.7.2.disable wdt ........... .............. .............. .............. .............. .............. ......... 166 14.7.3.disable wdt lockout ............... ................. ................ ................. ........... 166 14.7.4.setting wdt interval ........ ................ ................. .............. .............. ......... 166 15. oscillators ................ ................ ................ ................. ................ ................. ........... 171 15.1.programmable internal oscilla tor .................... .............. ............... ........... ....... 171 15.2.external oscillator drive circuit................ ................. .............. .............. ......... 173 15.3.system clock selectio n................. .............. .............. .............. .............. ......... 173 15.4.external crystal example .... ................. ................ ................. ................ ......... 175 15.5.external rc example .......... ................. ................ ................. ................ ......... 175 15.6.external capacitor example ... ................ ................ ................. .............. ......... 175 16. flash memory ................. ................ ................ ................. .............. .............. ......... 177 16.1.programming the flash memory ................ .............. .............. .............. ......... 177 16.2.non-volatile data storage ... ................. ................ ................. ................ ......... 178 16.3.security options ....... ................ ................ ................. .............. .............. ......... 179 16.3.1.summary of flash security options............. ................. ................ ......... 183 17. external data memory interface and on-chi p xram............ ................. ........... 187 17.1.accessing xram.......... ................. .............. .............. .............. .............. ......... 187 17.1.1.16-bit movx example ....... ................. .............. .............. .............. ......... 187 17.1.2.8-bit movx example ......... ................. .............. .............. .............. ......... 187 17.2.configuring the exte rnal memory interface . .............. .............. .............. ......... 188 17.3.port selection and c onfiguration.......... ................ ................. ................ ......... 188 17.4.multiplexed and non-multiplex ed selection.......... ................. ................ ......... 190 17.4.1.multiplexed configuration. ................ ................. .............. .............. ......... 190 17.4.2.non-multiplexed configurat ion.............. .............. .............. .............. ....... 191 17.5.memory mode selection...... ................. ................ ................. ................ ......... 192 17.5.1.internal xram only ......... ................ ................. .............. .............. ......... 192 17.5.2.split mode without bank select............. .............. .............. .............. ....... 192 17.5.3.split mode with ba nk select................ .............. .............. .............. ......... 193 17.5.4.external only...... ................ ................. .............. .............. .............. ......... 193 17.6.timing ............. ................ ................ ................. ................ ................. ........... 194 17.6.1.non-multiplexed mode ....... ................. .............. .............. .............. ......... 196 17.6.1.1.16-bit movx: emi0cf[4 :2] = ?101?, ?110?, or ?111?........... .............. 196 17.6.1.2.8-bit movx without bank selec t: emi0cf[4:2] = ?101? or ?111?..... 197 17.6.1.3.8-bit movx with b ank select: emi0cf[4:2] = ? 110?.............. ......... 198 17.6.2.multiplexed mode .... .............. .............. .............. .............. .............. ......... 199 17.6.2.1.16-bit movx: emi0cf[4 :2] = ?001?, ?010?, or ?011?........... .............. 199 17.6.2.2.8-bit movx without bank selec t: emi0cf[4:2] = ?001? or ?011?..... 200 17.6.2.3.8-bit movx with b ank select: emi0cf[4:2] = ? 010?.............. ......... 201 18. port input/output............ ................ ................ ................. .............. .............. ......... 203 18.1.ports 0 through 3 and the priority crossbar decoder.... ............... ........... ....... 205 18.1.1.crossbar pin assignment and allocation .......... .............. .............. ......... 205 18.1.2.configuring the output mo des of the port pins........ ............ ........... ....... 206 18.1.3.configuring port pins as digital inputs....... ................ ................. ........... 207 18.1.4.weak pull-ups ...... ................. .............. .............. .............. .............. ......... 207
c8051f060/1/2/3/4/5/6/7 6 rev. 1.2 18.1.5.configuring port 1 and 2 pi ns as analog inputs......... ................. ........... 207 18.1.6.crossbar pin assignment example.............. ................. ................ ......... 208 18.2.ports 4 through 7 (c8051f060/2/ 4/6 only) ............. ................. .............. ......... 219 18.2.1.configuring ports which are not pinned out .. ................. .............. ......... 219 18.2.2.configuring the output mo des of the port pins........ ............ ........... ....... 219 18.2.3.configuring port pins as digital inputs....... ................ ................. ........... 219 18.2.4.weak pull-ups ...... ................. .............. .............. .............. .............. ......... 219 18.2.5.external memory interfac e .................. .............. .............. .............. ......... 220 19. controller area network (can0 , c8051f060/1/2/3) ... ................. .............. ......... 225 19.1.bosch can controller operation................. .............. .............. .............. ......... 227 19.2.can registers..... ................ ................. ................ ................. ................ ......... 228 19.2.1.can controller protocol r egisters............... ................. ................ ......... 228 19.2.2.message object interface registers ............ ................. ................ ......... 228 19.2.3.message handler registers... ................. .............. ............... ........... ....... 228 19.2.4.cip-51 mcu special functi on registers .......... .............. .............. ......... 229 19.2.5.using can0adr, can0dath, an d candatl to access can registers 229 19.2.6.can0adr autoincr ement feature ......... .............. ............... ........... ....... 229 20. system management bus / i2 c bus (smbus0)...... ................. ................ ......... 235 20.1.supporting documents ............. ................ ................. .............. .............. ......... 236 20.2.smbus protocol........ ................ ................ ................. .............. .............. ......... 236 20.2.1.arbitration......... ................ ................ ................. .............. .............. ......... 237 20.2.2.clock low extension........ ................ ................. .............. .............. ......... 237 20.2.3.scl low timeout.... .............. .............. .............. .............. .............. ......... 237 20.2.4.scl high (smbus free) ti meout .............. ................ ................. ........... 237 20.3.smbus transfer modes... .............. .............. .............. .............. .............. ......... 238 20.3.1.master transmitter mode .. ............... ................. .............. .............. ......... 238 20.3.2.master receiver mode .............. ................. ................ ................. ........... 238 20.3.3.slave transmitter mode .... ............... ................. .............. .............. ......... 239 20.3.4.slave receiver mode ....... ................ ................. .............. .............. ......... 239 20.4.smbus special function regist ers ............... .............. .............. .............. ....... 241 20.4.1.control register ... ................. .............. .............. .............. .............. ......... 241 20.4.2.clock rate register ......... ................ ................. .............. .............. ......... 244 20.4.3.data register ....... ................. .............. .............. .............. .............. ......... 245 20.4.4.address register..... .............. .............. .............. .............. .............. ......... 245 20.4.5.status register............ ................. ................ ................. ................ ......... 246 21. enhanced serial peripheral interface (spi0)..... .............. .............. .............. ....... 251 21.1.signal descriptions....... ................. .............. .............. .............. .............. ......... 252 21.1.1.master out, slave in (mos i)...................... ................ ................. ........... 252 21.1.2.master in, slave out (miso)............... .............. .............. .............. ......... 252 21.1.3.serial clock (sck) ........... ................ ................. .............. .............. ......... 252 21.1.4.slave select (nss) .......... ................ ................. .............. .............. ......... 252 21.2.spi0 master mode operation . ................ ................ ................. .............. ......... 253 21.3.spi0 slave mode operation ..... ................ ................. .............. .............. ......... 255 21.4.spi0 interrupt sources ........ ................. ................ ................. ................ ......... 255
c8051f060/1/2/3/4/5/6/7 rev. 1.2 7 21.5.serial clock timing... ................ ................ ................. .............. .............. ......... 256 21.6.spi special function registers . ............... ................. .............. .............. ......... 258 22. uart0................ ................ ................ ................. .............. .............. .............. ......... 265 22.1.uart0 operational modes ...... ................ ................. .............. .............. ......... 266 22.1.1.mode 0: synchronous mode .. ................. .............. ............... ........... ....... 266 22.1.2.mode 1: 8-bit uart, variable baud rate.. ................ ................. ........... 267 22.1.3.mode 2: 9-bit uart, fix ed baud rate .......... ................. .............. ......... 269 22.1.4.mode 3: 9-bit uart, variable baud rate.. ................ ................. ........... 270 22.2.multiprocessor communications ... .............. .............. .............. .............. ......... 271 22.2.1.configuration of a mask ed address ............. ................. ................ ......... 271 22.2.2.broadcast addressing ............... ................. ................ ................. ........... 271 22.3.frame and transmission error detection........ .............. ............... ........... ....... 272 23. uart1................ ................ ................ ................. .............. .............. .............. ......... 277 23.1.enhanced baud rate g eneration.................. .............. .............. .............. ....... 278 23.2.operational modes ....... ................. .............. .............. .............. .............. ......... 279 23.2.1.8-bit uart ........... ................. .............. .............. .............. .............. ......... 279 23.2.2.9-bit uart ........... ................. .............. .............. .............. .............. ......... 280 23.3.multiprocessor communications ... .............. .............. .............. .............. ......... 281 24. timers................ ................ ................ .............. .............. ............... .............. ........... 28 7 24.1.timer 0 and ti mer 1 ............... ................ ................ ................. .............. ......... 287 24.1.1.mode 0: 13-bit counter/timer ................. .............. ............... ........... ....... 287 24.1.2.mode 1: 16-bit counter/timer ................. .............. ............... ........... ....... 289 24.1.3.mode 2: 8-bit counter/tim er with auto-reload.......... ................. ........... 289 24.1.4.mode 3: two 8-bit counter /timers (timer 0 only)..... ................. ........... 290 24.2.timer 2, timer 3, and timer 4 .... ................. .............. .............. .............. ......... 295 24.2.1.configuring timer 2, 3, and 4 to count down............ ................. ........... 295 24.2.2.capture mode ......... .............. .............. .............. .............. .............. ......... 296 24.2.3.auto-reload mode .... ................ ................. ................ ................. ........... 297 24.2.4.toggle output mode ........ ................ ................. .............. .............. ......... 298 25. programmable counter array ....... ................ ................. .............. .............. ......... 303 25.1.pca counter/timer ............. ................. ................ ................. ................ ......... 304 25.2.capture/compare modules ...... ................ ................. .............. .............. ......... 305 25.2.1.edge-triggered captur e mode................. .............. ............... ........... ....... 306 25.2.2.software timer (compare) mode................. ................. ................ ......... 307 25.2.3.high speed output mode............. ................ ................. ................ ......... 308 25.2.4.frequency output mode ....... .............. .............. .............. .............. ......... 309 25.2.5.8-bit pulse width modulato r mode............... ................. ................ ......... 310 25.2.6.16-bit pulse width modulat or mode............. ................. ................ ......... 311 25.3.register descriptions for pca0 ................ ................. .............. .............. ......... 312 26. jtag (ieee 1149.1) ........ ................ ................ ................. .............. .............. ......... 317 26.1.boundary scan ............. ................. .............. .............. .............. .............. ......... 318 26.1.1.extest instruction.......... ................ ................. .............. .............. ......... 321 26.1.2.sample instruction ......... ................ ................. .............. .............. ......... 321 26.1.3.bypass instruction ......... ................ ................. .............. .............. ......... 321 26.1.4.idcode instruction.......... ................ ................. .............. .............. ......... 321
c8051f060/1/2/3/4/5/6/7 8 rev. 1.2 26.2.flash programming commands.... .............. .............. .............. .............. ......... 322 26.3.debug support ........... ................ ................. .............. .............. .............. ......... 325 27. document change list .. ................ ................ ................. .............. .............. ......... 327 27.1.revision 1.1 to revisi on 1.2 ................. ................ ................. ................ ......... 327
c8051f060/1/2/3/4/5/6/7 rev. 1.2 9 list of figures 1. system overview............ ................ ................ ................. .............. .............. ........... 19 figure 1.1. c8051f060 / c8 051f062 block diagram .............. ............ ........... ......... 21 figure 1.2. c8051f061 / c8 051f063 block diagram .............. ............ ........... ......... 22 figure 1.3. c8051f064 / c8 051f066 block diagram .............. ............ ........... ......... 23 figure 1.4. c8051f065 / c8 051f067 block diagram .............. ............ ........... ......... 24 figure 1.5. comparison of peak mcu execution speeds ....... ............ ........... ......... 25 figure 1.6. on-board clo ck and reset ............... .............. .............. .............. ........... 26 figure 1.7. on-chip memory map..... ............... ................. .............. .............. ........... 27 figure 1.8. development/in-system debug diagram................. ................. ............. 28 figure 1.9. digital crossbar diagram .................. .............. .............. .............. ........... 29 figure 1.10. pca block diagram...... ................ ................. .............. .............. ........... 30 figure 1.11. can controller overvi ew ................ .............. .............. .............. ........... 31 figure 1.12. 16-bit adc block diagram .............. .............. .............. .............. ........... 33 figure 1.13. 10-bit adc diagram....... ................. .............. .............. .............. ........... 34 figure 1.14. dac system block diagr am ............... .............. ............... ........... ......... 35 figure 1.15. comparator bl ock diagram ............... .............. .............. .............. ......... 36 2. absolute maximum ratings ........ ................ ................ ................. .............. ........... 37 3. global dc electrical characteristi cs ...................... ................ ................. ............. 38 4. pinout and package definitions..... ............... ................. .............. .............. ........... 39 figure 4.1. c8051f060 / c8051f062 pinout diagram (tqfp-100) .............. ........... 45 figure 4.2. c8051f064 / c8051f066 pinout diagram (tqfp-100) .............. ........... 46 figure 4.3. tqfp-100 package drawin g ................ .............. ............... ........... ......... 47 figure 4.4. c8051f061 / c8051f063 pinout diagram (tqfp-64). ............... ........... 48 figure 4.5. c8051f065 / c8051f067 pinout diagram (tqfp-64). ............... ........... 49 figure 4.6. tqfp-64 package drawing . ................. .............. ............... ........... ......... 50 5. 16-bit adcs (adc0 and adc1) ....... ................. .............. .............. .............. ........... 51 figure 5.1. 16-bit adc0 and adc1 control path diagram ... ............... ........... ......... 51 figure 5.2. 16-bit adc0 and adc1 data path diagram ....... ............... ........... ......... 52 figure 5.3. voltage refer ence block diagram ........ .............. ............... ........... ......... 53 figure 5.4. adc track and conversi on example timing........... ................. ............. 55 figure 5.5. adc0 and adc1 equiva lent input circuits ............ ............ ........... ......... 56 figure 5.6. amx0sl: amux config uration register................ ............ ........... ......... 57 figure 5.7. adc0cf: adc0 confi guration register .... ................. ................ ........... 58 figure 5.8. adc1cf: adc1 confi guration register .... ................. ................ ........... 59 figure 5.9. adc0cn: adc0 control register......... .............. ............... ........... ......... 60 figure 5.10. adc1cn: adc1 control register ....... .............. ............... ........... ......... 61 figure 5.11. ref0cn: reference c ontrol register 0 .............. ............ ........... ......... 62 figure 5.12. ref1cn: reference c ontrol register 1 .............. ............ ........... ......... 62 figure 5.13. adc0h: adc0 data word msb register .. ................. .............. ........... 63 figure 5.14. adc0l: adc0 data word lsb r egister........... ............... ........... ......... 63 figure 5.15. adc0 data word exam ple.............. .............. .............. .............. ........... 64 figure 5.16. adc1h: adc1 data word msb register .. ................. .............. ........... 65
c8051f060/1/2/3/4/5/6/7 10 rev. 1.2 figure 5.17. adc1l: adc1 data word lsb r egister........... ............... ........... ......... 65 figure 5.18. adc1 data word exam ple.............. .............. .............. .............. ........... 65 figure 5.19. calibration coefficient locations....... .............. .............. .............. ......... 66 figure 5.20. offset and gain regist er mapping ........... ................. ................ ........... 67 figure 5.21. offset and gain calibration block diagram............ ................. ............. 67 figure 5.22. adc0cpt: ad c calibration pointer register ............... .............. ......... 68 figure 5.23. adc0ccf: ad c calibration coeffici ent register ............ ........... ......... 68 figure 5.24. adc0gth: adc0 gr eater-than data hi gh byte register .. ................ 69 figure 5.25. adc0gtl: adc0 gr eater-than data low byte r egister......... ........... 69 figure 5.26. adc0lth: adc0 less-than data hi gh byte register.... ........... ......... 70 figure 5.27. adc0ltl: adc0 less-than data low byte register ..... ........... ......... 70 figure 5.28. 16-bit adc0 window interrupt example: single -ended data .............. 71 figure 5.29. 16-bit adc0 window interrupt example: different ial data ....... ........... 72 6. direct memory access interfac e (dma0) ............... ................ ................. ............. 75 figure 6.1. dma0 block diagram..... ................ ................. .............. .............. ........... 75 figure 6.2. dma mode 0 op eration ............. ................ ................. ................ ........... 77 figure 6.3. dma mode 1 op eration ............. ................ ................. ................ ........... 78 figure 6.4. dma0cn: dma0 control register ............. ................. ................ ........... 80 figure 6.5. dma0cf: dma0 config uration register.... ................. ................ ........... 81 figure 6.6. dma0ipt: dma0 inst ruction write address register ............... ............. 82 figure 6.7. dma0idt: dma0 inst ruction write data register .. ........... ........... ......... 82 figure 6.8. dma0bnd: dma0 inst ruction boundary register ... ................. ............. 83 figure 6.9. dma0isw: dma0 inst ruction status register ....... ............ ........... ......... 83 figure 6.10. dma0dah: dma0 data address beginning msb register...... ........... 84 figure 6.11. dma0dal: dma0 data address beginning lsb regist er .................. 84 figure 6.12. dma0dsh: dma0 da ta address pointer msb regi ster ..................... 84 figure 6.13. dma0dsl: dma0 da ta address pointer lsb regi ster ............ ........... 84 figure 6.14. dma0cth: dma0 r epeat counter limit msb regi ster........... ........... 85 figure 6.15. dma0ctl: dma0 re peat counter limit lsb regi ster ............ ........... 85 figure 6.16. dma0csh: dma0 r epeat counter msb register ... ................ ........... 85 figure 6.17. dma0csl: dma0 r epeat counter lsb register..... ................ ........... 85 7. 10-bit adc (adc 2, c8051f060/1/2/3).......... ................ ................. .............. ........... 87 figure 7.1. adc2 functional block diagram........... .............. ............... ........... ......... 87 figure 7.2. temperature sensor transfer function ..... ................. ................ ........... 89 figure 7.3. 10-bit adc track a nd conversion example timing ... ................ ........... 90 figure 7.4. adc2 equivalent input circuits......... .............. .............. .............. ........... 91 figure 7.5. amx2cf: amux2 confi guration register ............... ................. ............. 92 figure 7.6. amx2sl: amux2 channel select register. ................. .............. ........... 93 figure 7.7. adc2cf: adc2 confi guration register .... ................. ................ ........... 94 figure 7.8. adc2h: adc2 data word msb register .............. ............ ........... ......... 95 figure 7.9. adc2l: adc2 data word lsb register ............. ............... ........... ......... 95 figure 7.10. adc2cn: adc2 control register ....... .............. ............... ........... ......... 96 figure 7.11. adc2gth: adc2 gr eater-than data hi gh byte register .. ................ 97 figure 7.12. adc2gtl: adc2 gr eater-than data low byte r egister......... ........... 97 figure 7.13. adc2lth: adc2 less-than data hi gh byte register.... ........... ......... 98
c8051f060/1/2/3/4/5/6/7 rev. 1.2 11 figure 7.14. adc2ltl: adc2 less-than data low byte register ..... ........... ......... 98 figure 7.15. adc window com pare example: right-justi fied single-ended data . 99 figure 7.16. adc window compar e example: left-justifi ed single-ended data.... 99 figure 7.17. adc window compare example: right-justified differential data.... 100 figure 7.18. adc window compare example: left-justified differential data ...... 100 8. dacs, 12-bit voltag e mode (dac0 and dac1, c8051f 060/1/2/3) ......... ........... 103 figure 8.1. dac functional block diagram............. .............. ............... ........... ....... 103 figure 8.2. dac0h: dac0 high byte register ............ ................. ................ ......... 105 figure 8.3. dac0l: dac0 low byte register.............. ................. ................ ......... 105 figure 8.4. dac0cn: dac0 control register......... .............. ............... ........... ....... 106 figure 8.5. dac1h: dac1 high byte register ............ ................. ................ ......... 107 figure 8.6. dac1l: dac1 low byte register.............. ................. ................ ......... 107 figure 8.7. dac1cn: dac1 control register......... .............. ............... ........... ....... 108 9. voltage reference 2 (c8051f060/2) ................. .............. .............. .............. ......... 111 figure 9.1. voltage reference f unctional block diagram ......... ................. ........... 111 figure 9.2. ref2cn: reference cont rol register 2 ................ ............ ........... ....... 112 10. voltage reference 2 (c8051f061/3) ................ .............. .............. .............. ......... 113 figure 10.1. voltage reference fu nctional block diagram........ ................. ........... 113 figure 10.2. ref2cn: reference c ontrol register 2 .............. ............ ........... ....... 114 11. voltage reference 2 (c8051f064/5/ 6/7) ............. .............. .............. .............. ....... 115 figure 11.1. voltage reference fu nctional block diagram........ ................. ........... 115 figure 11.2. ref2cn: reference c ontrol register 2 .............. ............ ........... ....... 116 12. comparators ................ ................. ................ ................ ................. .............. ......... 117 figure 12.1. comparator functiona l block diagram ...... ................. .............. ......... 117 figure 12.2. comparator hysteresis plot ............ .............. .............. .............. ......... 118 figure 12.3. cptncn: com parator 0, 1, and 2 control regi ster ............. .............. 120 figure 12.4. cptnmd: com parator mode selection register ................. .............. 121 13. cip-51 microcontroller .............. ................. ................ ................. ................ ......... 123 figure 13.1. cip-51 block diagram.. ............... ................. .............. .............. ......... 124 figure 13.2. memory map .............. ................ ................ ................. .............. ......... 130 figure 13.3. sfr page stack... ................. ................. ................ ................. ........... 133 figure 13.4. sfr page stack wh ile using sfr page 0x0f to access port 5...... 134 figure 13.5. sfr page stack af ter adc2 window comparator interrupt occurs . 135 figure 13.6. sfr page stack u pon pca interrupt occurring during an adc2 isr.... 136 figure 13.7. sfr page sta ck upon return from pca interr upt ................ ........... 137 figure 13.8. sfr page stack u pon return from adc2 window interrupt ........... 138 figure 13.9. sfrpgcn: sf r page control regist er ................ ................. ........... 139 figure 13.10. sfrpage: sfr page register ............. ................. ................ ......... 139 figure 13.11. sfrnext: sfr next r egister............... ................. ................ ......... 140 figure 13.12. sfrlast: sfr last r egister................ ................. ................ ......... 140 figure 13.13. sp: stack pointer ....... ................ ................. .............. .............. ......... 148 figure 13.14. dpl: data po inter low byte............ .............. .............. .............. ....... 148 figure 13.15. dph: data pointer hi gh byte ................. ................. ................ ......... 148 figure 13.16. psw: program status word.............. .............. ............... ........... ....... 149
c8051f060/1/2/3/4/5/6/7 12 rev. 1.2 figure 13.17. acc: accumulator...... ................ ................. .............. .............. ......... 150 figure 13.18. b: b register ............ ................ ................ ................. .............. ......... 150 figure 13.19. ie: interrupt enable ..... ............... ................. .............. .............. ......... 154 figure 13.20. ip: interrupt priority .. ................ ................ ................. .............. ......... 155 figure 13.21. eie1: extended interrup t enable 1......... ................. ................ ......... 156 figure 13.22. eie2: extended interrup t enable 2......... ................. ................ ......... 157 figure 13.23. eip1: extended in terrupt priority 1.... .............. ............... ........... ....... 158 figure 13.24. eip2: extended in terrupt priority 2.... .............. ............... ........... ....... 159 figure 13.25. pcon: power control .. ................. .............. .............. .............. ......... 161 14. reset sources.......... ................ ................ ................. ................ ................. ........... 163 figure 14.1. reset sources............ ................ ................ ................. .............. ......... 163 figure 14.2. reset timing .............. ................ ................ ................. .............. ......... 164 figure 14.3. wdtcn: watchdog timer control regi ster........... ................. ........... 167 figure 14.4. rstsrc: reset source register ....... .............. ............... ........... ....... 168 15. oscillators ................ ................ ................ ................. ................ ................. ........... 171 figure 15.1. oscillator diagram...... ................ ................ ................. .............. ......... 171 figure 15.2. oscicl: internal o scillator calibration register .. ........... ........... ....... 172 figure 15.3. oscicn: internal o scillator control register ...... ............ ........... ....... 172 figure 15.4. clksel: oscillator cl ock selection register ........ ................. ........... 173 figure 15.5. oscxcn: external o scillator control register.... ............ ........... ....... 174 16. flash memory ................. ................ ................ ................. .............. .............. ......... 177 figure 16.1. c8051f060/1/2/3/4/5 flash progr am memory map and security bytes .. 180 figure 16.2. c8051f066/7 flash program memory map and security bytes ........ 181 figure 16.3. flacl: flash access li mit ............... .............. .............. .............. ....... 182 figure 16.4. flscl: flash memory control.......... .............. .............. .............. ....... 184 figure 16.5. psctl: program stor e read/write control......... ............ ........... ....... 185 17. external data memory interface and on-chi p xram............ ................. ........... 187 figure 17.1. emi0cn: exter nal memory interface control .... ............... ........... ....... 189 figure 17.2. emi0cf: external me mory configuration............. ............ ........... ....... 189 figure 17.3. multiplexed configurat ion example.......... ................. ................ ......... 190 figure 17.4. non-multiplexed conf iguration example .............. ............ ........... ....... 191 figure 17.5. emif operati ng modes .............. ................ ................. .............. ......... 192 figure 17.6. emi0tc: external me mory timing control............. ................. ........... 194 figure 17.7. non-multiplexed 16-bi t movx timing ...... ................. ................ ......... 196 figure 17.8. non-multiplexed 8-bi t movx without bank select timing ................. 197 figure 17.9. non-multiplexed 8-bi t movx with bank select ti ming ........... ........... 198 figure 17.10. multiplexed 16-bit mo vx timing............ ................. ................ ......... 199 figure 17.11. multiplexed 8-bit mo vx without bank select ti ming ............ ........... 200 figure 17.12. multiplexed 8-bit mo vx with bank select timing ................. ........... 201 18. port input/output............ ................ ................ ................. .............. .............. ......... 203 figure 18.1. port i/o cell block diagram ............ .............. .............. .............. ......... 203 figure 18.2. port i/o func tional block diagram ...... .............. ............... ........... ....... 204 figure 18.3. priority crossbar de code table ............. ................ ................. ........... 205 figure 18.4. crossbar example:....... ................ ................. .............. .............. ......... 209
c8051f060/1/2/3/4/5/6/7 rev. 1.2 13 figure 18.5. xbr0: port i/ o crossbar register 0.............. .............. .............. ......... 210 figure 18.6. xbr1: port i/ o crossbar register 1.............. .............. .............. ......... 211 figure 18.7. xbr2: port i/ o crossbar register 2.............. .............. .............. ......... 212 figure 18.8. xbr3: port i/ o crossbar register 3.............. .............. .............. ......... 213 figure 18.9. p0: port0 data register ............... ................. .............. .............. ......... 214 figure 18.10. p0mdout: port0 out put mode register ............. ................. ........... 214 figure 18.11. p1: port1 data regist er ............. ................. .............. .............. ......... 215 figure 18.12. p1mdin: port1 input mode register........ ................. .............. ......... 215 figure 18.13. p1mdout: port1 out put mode register ............. ................. ........... 216 figure 18.14. p2: port2 data regist er ............. ................. .............. .............. ......... 216 figure 18.15. p2mdin: port2 input mode register........ ................. .............. ......... 217 figure 18.16. p2mdout: port2 out put mode register ............. ................. ........... 217 figure 18.17. p3: port3 data regist er ............. ................. .............. .............. ......... 218 figure 18.18. p3mdout: port3 out put mode register ............. ................. ........... 218 figure 18.19. p4: port4 data regist er ............. ................. .............. .............. ......... 221 figure 18.20. p4mdout: port4 out put mode register ............. ................. ........... 221 figure 18.21. p5: port5 data regist er ............. ................. .............. .............. ......... 222 figure 18.22. p5mdout: port5 out put mode register ............. ................. ........... 222 figure 18.23. p6: port6 data regist er ............. ................. .............. .............. ......... 223 figure 18.24. p6mdout: port6 out put mode register ............. ................. ........... 223 figure 18.25. p7: port7 data regist er ............. ................. .............. .............. ......... 224 figure 18.26. p7mdout: port7 out put mode register ............. ................. ........... 224 19. controller area network (can0 , c8051f060/1/2/3) ... ................. .............. ......... 225 figure 19.1. can controller diagram ............... ................. .............. .............. ......... 226 figure 19.2. typical can bus confi guration................ ................. ................ ......... 226 figure 19.3. can0dath: can data access regist er high byte ........ ........... ....... 231 figure 19.4. can0datl: can data access regist er low byte.......... ........... ....... 231 figure 19.5. can0adr: ca n address index register ......... ............... ........... ....... 232 figure 19.6. can0cn: can control register .............. ................. ................ ......... 232 figure 19.7. can0tst: can test r egister ................. ................. ................ ......... 233 figure 19.8. can0sta: can status register......... .............. ............... ........... ....... 233 20. system management bus / i2 c bus (smbus0)...... ................. ................ ......... 235 figure 20.1. smbus0 block diagram . ................. .............. .............. .............. ......... 235 figure 20.2. typical smbus configur ation ............ .............. .............. .............. ....... 236 figure 20.3. smbus transaction ...... ................ ................. .............. .............. ......... 237 figure 20.4. typical mast er transmitter sequence............... ............... ........... ....... 238 figure 20.5. typical master receiver sequence................... ............... ........... ....... 238 figure 20.6. typical slave transmi tter sequence........ ................. ................ ......... 239 figure 20.7. typical slave receiver sequence....... .............. ............... ........... ....... 240 figure 20.8. smb0cn: smbus0 cont rol register........ ................. ................ ......... 243 figure 20.9. smb0cr: smbus0 clo ck rate register.... ................. .............. ......... 244 figure 20.10. smb0dat: smbus0 da ta register........ ................. ................ ......... 245 figure 20.11. smb0adr: smbus0 a ddress register....... .............. .............. ......... 246 figure 20.12. smb0sta: smbus0 st atus register ....... ................. .............. ......... 247 21. enhanced serial peripheral interface (spi0)..... .............. .............. .............. ....... 251
c8051f060/1/2/3/4/5/6/7 14 rev. 1.2 figure 21.1. spi block diagram ................ ................. ................ ................. ........... 251 figure 21.2. multiple-master mo de connection diagram .. .............. .............. ......... 254 figure 21.3. 3-wire single ma ster and 3-wire single slave mode connection diagram 254 figure 21.4. 4-wire si ngle master mode an d 4-wire slave m ode connection diagram 254 figure 21.5. master mode data/clo ck timing .............. ................. ................ ......... 256 figure 21.6. slave mode data/clock timing (ckpha = 0) ... ............... ........... ....... 257 figure 21.7. slave mode data/clock timing (ckpha = 1) ... ............... ........... ....... 257 figure 21.8. spi0cfg: spi0 configuration register ............ ............... ........... ....... 258 figure 21.9. spi0cn: spi0 control register......... .............. .............. .............. ....... 259 figure 21.10. spi0ckr: spi0 clock rate register ... ................ ................. ........... 260 figure 21.11. spi0dat: spi0 data register........... .............. ............... ........... ....... 261 figure 21.12. spi master timing (c kpha = 0).............. ................. .............. ......... 262 figure 21.13. spi master timing (c kpha = 1).............. ................. .............. ......... 262 figure 21.14. spi slave timing (ckpha = 0)......... .............. ............... ........... ....... 263 figure 21.15. spi slave timing (ckpha = 1)......... .............. ............... ........... ....... 263 22. uart0................ ................ ................ ................. .............. .............. .............. ......... 265 figure 22.1. uart0 block di agram ............... ................ ................. .............. ......... 265 figure 22.2. uart0 mode 0 timing diagram ............ ................ ................. ........... 267 figure 22.3. uart0 mode 0 in terconnect............... .............. ............... ........... ....... 267 figure 22.4. uart0 mode 1 timing diagram ............ ................ ................. ........... 267 figure 22.5. uart0 modes 2 and 3 timing diagram .............. ............ ........... ....... 269 figure 22.6. uart0 modes 1, 2, and 3 interconnect diagram ............ ........... ....... 270 figure 22.7. uart multi-processor mode inte rconnect diagram ........ ........... ....... 272 figure 22.8. scon0: uart0 contro l register ............ ................. ................ ......... 274 figure 22.9. ssta0: uart0 stat us and clock selection register ............... ......... 275 figure 22.10. sbuf0: uart0 data buffer register .... ................. ................ ......... 276 figure 22.11. saddr0: uart0 slav e address register .......... ................. ........... 276 figure 22.12. saden0: uart0 slav e address enable register .. ............... ......... 276 23. uart1................ ................ ................ ................. .............. .............. .............. ......... 277 figure 23.1. uart1 block di agram ............... ................ ................. .............. ......... 277 figure 23.2. uart1 baud ra te logic ............ ................ ................. .............. ......... 278 figure 23.3. uart interconnect diagr am ............... .............. ............... ........... ....... 279 figure 23.4. 8-bit uart timing diagr am................ .............. ............... ........... ....... 279 figure 23.5. 9-bit uart timing diagr am................ .............. ............... ........... ....... 280 figure 23.6. uart multi-processor mode inte rconnect diagram ........ ........... ....... 281 figure 23.7. scon1: serial port 1 control regist er ................ ............ ........... ....... 282 figure 23.8. sbuf1: serial (uar t1) port data buffer regist er ................. ........... 283 24. timers................ ................ ................ .............. .............. ............... .............. ........... 28 7 figure 24.1. t0 mode 0 block diagram ................. .............. .............. .............. ....... 288 figure 24.2. t0 mode 2 block diagram ................. .............. .............. .............. ....... 289 figure 24.3. t0 mode 3 block diagram ................. .............. .............. .............. ....... 290 figure 24.4. tcon: timer control r egister ................. ................. ................ ......... 291 figure 24.5. tmod: timer mode regi ster .............. .............. ............... ........... ....... 292
c8051f060/1/2/3/4/5/6/7 rev. 1.2 15 figure 24.6. ckcon: clock control register ......... .............. ............... ........... ....... 293 figure 24.7. tl0: timer 0 low byte .. ............... ................. .............. .............. ......... 294 figure 24.8. tl1: timer 1 low byte .. ............... ................. .............. .............. ......... 294 figure 24.9. th0: timer 0 high byte ................ ................. .............. .............. ......... 294 figure 24.10. th1: timer 1 high byte ................. .............. .............. .............. ......... 294 figure 24.11. t2, 3, and 4 captur e mode block diagram .......... ................. ........... 296 figure 24.12. t2, 3, and 4 auto-r eload mode block diagram ....... ................ ......... 297 figure 24.13. tmrncn: timer 2, 3, and 4 control registers .... ................. ........... 299 figure 24.14. tmrncf: timer 2, 3, and 4 confi guration registers ..... ........... ....... 300 figure 24.15. rcapnl: timer 2, 3, and 4 capture register low byte ......... ......... 301 figure 24.16. rcapnh: timer 2, 3, and 4 capture r egister high byte.. ............... 301 figure 24.17. tmrnl: timer 2, 3, and 4 low byte.............. .............. .............. ....... 301 figure 24.18. tmrnh: timer 2, 3, and 4 high byte ....... ................. .............. ......... 302 25. programmable counter array ....... ................ ................. .............. .............. ......... 303 figure 25.1. pca block diagram...... ................ ................. .............. .............. ......... 303 figure 25.2. pca counter/timer bl ock diagram.......... ................. ................ ......... 304 figure 25.3. pca interrupt block di agram .............. .............. ............... ........... ....... 305 figure 25.4. pca capture m ode diagram............... .............. ............... ........... ....... 306 figure 25.5. pca software timer mode diagram .......... ................. .............. ......... 307 figure 25.6. pca high speed output mode diagram.. ................. ................ ......... 308 figure 25.7. pca frequency ou tput mode ............. .............. ............... ........... ....... 309 figure 25.8. pca 8-bit pwm mode di agram ............. ................ ................. ........... 310 figure 25.9. pca 16-bit pwm mode..... .............. .............. .............. .............. ......... 311 figure 25.10. pca0cn: pca control register .............. ................. .............. ......... 312 figure 25.11. pca0md: pca0 mode r egister............... ................. .............. ......... 313 figure 25.12. pca0cpmn: pca0 capture/compare m ode registers..... .............. 314 figure 25.13. pca0l: pca0 counter /timer low byte............... ................. ........... 315 figure 25.14. pca0h: pca0 counter /timer high byte .... .............. .............. ......... 315 figure 25.15. pca0cpln: pca0 ca pture module low byte ........ ................ ......... 316 figure 25.16. pca0cphn: pca0 capture module high byte.............. ........... ....... 316 26. jtag (ieee 1149.1) ........ ................ ................ ................. .............. .............. ......... 317 figure 26.1. ir: jtag inst ruction register.......... .............. .............. .............. ......... 317 figure 26.2. deviceid: jtag device id register ...... ................. ................ ......... 321 figure 26.3. flashcon: jtag flas h control register............ ................. ........... 323 figure 26.4. flashdat: jtag flas h data register.... ................ ................ ......... 324 figure 26.5. flashadr: jtag flas h address register........... ................. ........... 324 27. document change list .. ................ ................ ................. .............. .............. ......... 327
c8051f060/1/2/3/4/5/6/7 16 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 17 list of tables 1. system overview ........ ................. ................ ................ ................. .............. ........... 19 table 1.1.product selection guide .. ................ ................. .............. .............. ........... 20 2. absolute maximum ratings ....... ................ ................ ................. .............. ........... 37 table 2.1.absolute maximum rating s* .............. .............. .............. .............. ........... 37 3. global dc electrical characteris tics .............. .............. .............. .............. ........... 38 table 3.1.global dc electrical c haracteristics ......... ................ ................. ............. 38 4. pinout and package definitions .... ............... ................. .............. .............. ........... 39 table 4.1.pin definitions .......... ................ ................. ................ ................. ............. 39 5. 16-bit adcs (adc0 and adc1) .... ................ ................. .............. .............. ........... 51 table 5.1.conversion timing (tconv ) .............. ................. .............. .............. ........... 55 table 5.2.16-bit adc0 and adc1 electrical characteristics .. ............ ........... ......... 73 table 5.3.voltage reference 0 and 1 electrical characteristics ...... .............. ......... 74 6. direct memory access interfac e (dma0) .............. ................ ................. ............. 75 table 6.1.dma0 instruction set .... ................ ................ ................. .............. ........... 76 7. 10-bit adc (adc 2, c8051f060/1/2/3) ......... ................ ................. .............. ........... 87 table 7.1.adc2 electrical characte ristics ......... .............. .............. .............. ......... 101 8. dacs, 12-bit voltage mode (dac0 and dac1, c8051f060/ 1/2/3) ................... 103 table 8.1.dac electrical characte ristics ........... .............. .............. .............. ......... 109 9. voltage reference 2 (c8051f060/2) ................ .............. .............. .............. ......... 111 table 9.1.voltage reference elec trical characteristics .......... ............ ........... ....... 112 10. voltage reference 2 (c8051f061/3) ............... .............. .............. .............. ......... 113 table 10.1.voltage reference elec trical characteristics ........ ............ ........... ....... 114 11. voltage reference 2 (c8051f064/5/ 6/7) ............ .............. .............. .............. ....... 115 table 11.1.voltage reference elec trical characteristics ........ ............ ........... ....... 116 12. comparators ............... ................. ................ ................ ................. .............. ......... 117 table 12.1.comparator electrical characteristics ..... ................ ................. ........... 122 13. cip-51 microcontroller ............. ................. ................ ................. ................ ......... 123 table 13.1.cip-51 instruct ion set summary ........ .............. .............. .............. ....... 126 table 13.2.special function re gister (sfr) memory map ..... ............ ........... ....... 141 table 13.3.special function regist ers ................... .............. ............... ........... ....... 143 table 13.4.interrupt summary ....... ................ ................ ................. .............. ......... 152 14. reset sources ............. ................. ................ ................ ................. .............. ......... 163 table 14.1.reset electrical characteristics ..... ................. .............. .............. ......... 169 15. oscillators ............... ................ ................ ................. ................ ................. ........... 171 table 15.1.internal oscill ator electrical characteristics ... .............. .............. ......... 173 16. flash memory ............. ................. ................ ................ ................. .............. ......... 177 table 16.1.flash electrical characteristics ........ .............. .............. .............. ......... 178 17. external data memory interface and on-chip xram ........... ................. ........... 187 table 17.1.ac parameters for ex ternal memory interface ...... ............ ........... ....... 202 18. port input/output ........ ................. ................ ................ ................. .............. ......... 203 table 18.1.port i/o dc electrical characteristics ... .............. ............... ........... ....... 203 19. controller area network (can0 , c8051f060/1/2/3) .. ................. .............. ......... 225
c8051f060/1/2/3/4/5/6/7 18 rev. 1.2 table 19.1.can register index and reset values ..... ................. ................ ......... 229 20. system management bus / i2 c bus (smbus0) ..... ................. ................ ......... 235 table 20.1.smb0sta status codes and states ......... ................. ................ ......... 248 21. enhanced serial peripheral interface (spi0) .. .............. .............. .............. ......... 251 table 21.1.spi slave timing parame ters ............ .............. .............. .............. ....... 264 22. uart0 ................. ................ ................. .............. .............. .............. .............. ......... 265 table 22.1.uart0 modes ............. ................ ................ ................. .............. ......... 266 table 22.2.oscillator frequencie s for standard baud rates ....... ................ ......... 273 23. uart1 ................. ................ ................. .............. .............. .............. .............. ......... 277 table 23.1.timer settings for standard baud rates using the internal oscillator 284 table 23.2.timer settings for standard baud rates using an external oscillator 284 table 23.3.timer settings for standard baud rates using an external oscillator 285 table 23.4.timer settings for standard baud rates using an external oscillator 285 table 23.5.timer settings for standard baud rates using an external oscillator 286 table 23.6.timer settings for standard baud rates using an external oscillator 286 24. timers ................... ................. ................ ................ ................. ................ .............. 28 7 25. programmable counter array ...... ................ ................. .............. .............. ......... 303 table 25.1.pca timebase i nput options ............. .............. .............. .............. ....... 304 table 25.2.pca0cpm register settings for pca captur e/compare modules ..... 305 26. jtag (ieee 1149.1) ....... ................ ................ ................. .............. .............. ......... 317 table 26.1.boundary data regi ster bit definitions (c8051f 060/2/4/6) ..... ........... 318 table 26.2.boundary data regi ster bit definitions (c8051f 061/3/5/7) ..... ........... 320 27. document change list .......... ................ ................. ................ ................. ........... 327
c8051f060/1/2/3/4/5/6/7 rev. 1.2 19 1. system overview the c8051f06x family of devices are fully integrated mixed-signal system-on-a-chip mcus with 59 digital i/o pins (c8051f060/2/4/6) or 24 digital i/o pins (c8051f061/3/5/7), and two integrated 16-bit 1 msps adcs. highlighted features are listed below; refer to table 1.1 for specific product feature selection. ? high-speed pipelined 8051-compatible cip-51 microcontroller core (up to 25 mips) ? two 16-bit 1 msps adcs with a direct memory access controller ? controller area network (can 2.0b ) controller with 32 message object s, each with its own indentifier mask (c8051f060/1/2/3) ? in-system, full-speed, non-intrusive debug interface on-chip ? 10-bit 200 ksps adc with pga and 8-channel analog multiplexer (c8051f060/1/2/3) ? two 12-bit dacs with programmable update scheduling (c8051f060/1/2/3) ? 64 kb (c8051f060/1/2/3/4/5) or 32 kb (c8051 f066/7) of in-system programmable flash memory ? 4352 (4096 + 256) bytes of on-chip ram ? external data memory interf ace with 64 kb direct ad dress space (c8051f060/2/4/6) ? spi, smbus/i2c, and (2) uart serial interfaces implemented in hardware ? five general purpose 16-bit timers ? programmable counter/timer array with six capture/compare modules ? on-chip watchdog timer, vdd monitor, and temperature sensor with on-chip vdd monitor, watchdog timer, and clock oscillator, the c8051f06x fa mily of devices are truly stand-alone system-on-a-chip solutions. all analog and digital peripherals are enabled/disabled and con- figured by user firmware. the flash memory can be reprogrammed even in-circuit, providing non-volatile data storage, and also allowing field upgrades of the 8051 firmware. on-board jtag debug circuitry allows non-intrusive (uses no on-chip resource s), full speed, in-circuit debugging using the production mcu installed in the fina l application. this debug system supports inspec- tion and modification of memory and registers, settin g breakpoints, watchpoints, single stepping, run and halt commands. all analog and digital peripherals are fully functional while debugging using jtag. each mcu is specified for 2.7 to 3.6 v operation over the industrial temperature range (-45 to +85 c). the c8051f060/2/4/6 are available in a 100-pin tqfp pa ckage and the c8051f061/3/5/7 are available in a 64-pin tqfp package (see block diagrams in fi gure 1.1, figure 1.2, fi gure 1.3 and figure 1.4).
c8051f060/1/2/3/4/5/6/7 20 rev. 1.2 table 1.1. product selection guide mips (peak) flash memory ram external memory interface smbus/i2c and spi can uarts timers (16-bit) programmable counter array digital port i/o?s 16-bit 1 msps adc typical inl (lsbs) 10-bit 200 ksps adc inputs voltage reference temperature sensor dac resolution (bits) dac outputs analog comparators package c8051f060 25 64 k 4352 333 25 3 59 0.75 8 33 12 2 3 100 tqfp c8051f061 25 64 k 4352 - 33 25 3 24 0.75 8 33 12 2 3 64 tqfp c8051f062 25 64 k 4352 333 25 3 59 1.5 8 33 12 2 3 100 tqfp c8051f063 25 64 k 4352 - 33 25 3 24 1.5 8 33 12 2 3 64 tqfp c8051f064 25 64 k 4352 33 -25 3 59 0.75 - 3 - - - 3 100 tqfp c8051f065 25 64 k 4352 - 3 -25 3 24 0.75 - 3 ---364tqfp c8051f066 25 32 k 4352 33 -25 3 59 0.75 - 3 - - - 3 100 tqfp c8051f067 25 32 k 4352 - 3 -25 3 24 0.75 - 3 ---364tqfp
c8051f060/1/2/3/4/5/6/7 rev. 1.2 21 figure 1.1. c8051f060 / c8051f062 block diagram p0, p1, p2, p3 latches jtag logic tck tms tdi tdo uart 1 smbus spi bus pca 64kbyte flash 256 byte ram vdd monitor sfr bus 8 0 5 1 c o r e timers 0, 1, 2,3,4 p0 drv c r o s s b a r reset /rst xtal1 xtal2 external oscillator circuit system clock trimmed internal oscillator di gi tal power analog power debug hw boundary scan 4kbyte ram p2.0 p2.7 p1.0/ ain2.0 p1.7/ ain2.7 p0.0 p0.7 p1 drv p2 drv data bus address bus bus control dac0 dac0 (12-bi t) vref vref uart 0 p3.0 p3.7 p3 drv adc2 2 0 0 ksp s (10-bi t) a m u x monen wdt vref2 vrefd p4 latch p7 latch p5 latch p6 latch p7.0 p7.7 p7 drv p5.0 p5.7 p5 drv p6.0 p6.7 p6 drv p4 drv p4.5 p4.6 p4.7 external data memory bus addr[7:0] addr[15:8] ctrl latch data latch cantx canrx can 2.0b adc0 1msps (16-bit) vrgnd0 a d c 0 d a t a a d c 1 d a t a - + d i f f dma interface dac1 temp sensor emif control vdd vdd vdd dgnd dgnd dgnd av+ agnd vref0 agnd av+ vrgnd 1 vref1 agnd avdd ain0 ain0g vbgap 0 cnvstr 0 adc1 1msps (16-bit) agnd av+ ain1 ain1g vbgap 1 cnvstr 1 32x136 canram p2.7 p2.6 + - cp0 p2.3 p2.2 + - cp1 p2.5 p2.4 + - cp2
c8051f060/1/2/3/4/5/6/7 22 rev. 1.2 figure 1.2. c8051f061 / c8051f063 block diagram p3 drv p0, p1, p2, p3 latches jtag logic tck tms tdi tdo uart 1 smbus spi bus pca 64kbyte flash 256 byte ram vdd monitor sfr bus 8 0 5 1 c o r e timers 0, 1, 2,3,4 p0 drv c r o s s b a r reset /rst xtal1 xtal2 external oscillator ci rcui t system clock trimmed internal oscillator di gi tal power analog power debug hw boundary scan 4kbyte ram p2.0 p2.7 p1.0/ ain2.0 p1.7/ ain2.7 p0.0 p0.7 p1 drv p2 drv dac0 dac0 (12-bi t) vref vref uart 0 adc2 2 0 0 ksp s (10-bi t) a m u x monen wdt vref2 vref2 external data memory bus cantx canrx can 2.0b adc0 1msps (16-bit) vrgnd0 a d c 0 d a t a a d c 1 d a t a - + d i f f dma interface dac1 temp sensor emif control vdd vdd vdd dgnd dgnd dgnd av+ agnd vref0 agnd av+ vrgnd 1 vref1 agnd avdd ain0 ain0g vbgap 0 cnvstr 0 adc1 1msps (16-bit) agnd av+ ain1 ain1g vbgap 1 cnvstr 1 32x136 canram p2.7 p2.6 + - cp0 p2.3 p2.2 + - cp1 p2.5 p2.4 + - cp2 p4 latch p7 latch p5 latch p6 latch p7 drv p5 drv p6 drv p4 drv addr[7:0] addr[15:8] ctrl latch data latch
c8051f060/1/2/3/4/5/6/7 rev. 1.2 23 figure 1.3. c8051f064 / c8051f066 block diagram p0, p1, p2, p3 latches jtag logic tck tms tdi tdo uart1 smbus spi bus pca 256 byte ram vdd monitor sfr bus 8 0 5 1 c o r e timers 0, 1, 2,3,4 p0 drv c r o s s b a r reset /rst xtal1 xtal2 external oscillator circuit system clock trimmed internal oscillator digital power analog power debug hw boundary scan 4kbyte ram p2.0 p2.7 p1.0 p1.7 p0.0 p0.7 p1 drv p2 drv data bus address bus bus control vref vref uart0 p3.0 p3.7 p3 drv monen wdt p4 latch p7 latch p5 latch p6 latch p7.0 p7.7 p7 drv p5.0 p5.7 p5 drv p6.0 p6.7 p6 drv p4 drv p4.5 p4.6 p4.7 external data memory bus addr[7:0] addr[15:8] ctrl latch data latch adc0 1msps (16-bit) vrgnd0 a d c 0 d a t a a d c 1 d a t a - + d i f f dma interface emif control vdd vdd vdd dgnd dgnd dgnd av+ agnd vref0 agnd av+ vrgnd1 vref1 agnd avdd ain0 ain0g vbgap0 cnvstr0 adc1 1msps (16-bit) agnd av+ ain1 ain1g vbgap1 cnvstr1 p2.3 p2.2 + - cp1 p2.5 p2.4 + - cp2 p2.7 p2.6 + - cp0 flash memory 64k byte (c8051f064) 32k byte (c8051f066)
c8051f060/1/2/3/4/5/6/7 24 rev. 1.2 figure 1.4. c8051f065 / c8051f067 block diagram p3 drv p0, p1, p2, p3 latches jtag logic tck tms tdi tdo uart1 smbus spi bus pca flash memory 64k byte (c8051f065) 32k byte (c8051f067) 256 byte ram vdd monitor sfr bus 8 0 5 1 c o r e timers 0, 1, 2,3,4 p0 drv c r o s s b a r reset /rst xtal1 xtal2 external oscillator circuit system clock trimmed internal oscillator digital power analog power debug hw boundary scan 4kbyte ram p2.0 p2.7 p1.0 p1.7 p0.0 p0.7 p1 drv p2 drv vref vref uart0 monen wdt external data memory bus adc0 1msps (16-bit) vrgnd0 a d c 0 d a t a a d c 1 d a t a - + d i f f dma interface emif control vdd vdd vdd dgnd dgnd dgnd av+ agnd vref0 agnd av+ vrgnd1 vref1 agnd avdd ain0 ain0g vbgap0 cnvstr0 adc1 1msps (16-bit) agnd av+ ain1 ain1g vbgap1 cnvstr1 p4 latch p7 latch p5 latch p6 latch p7 drv p5 drv p6 drv p4 drv addr[7:0] addr[15:8] ctrl latch data latch p2.3 p2.2 + - cp1 p2.5 p2.4 + - cp2 p2.7 p2.6 + - cp0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 25 1.1. cip-51? microcontroller core 1.1.1. fully 8051 compatible the c8051f06x family of devices ut ilizes silicon labs' proprietary ci p-51 microcontroller core. the cip- 51 is fully compatible with the mc s-51? instruction set; standard 803x/805x assemblers and compilers can be used to develop software. the core has all t he peripherals included with a standard 8052, including five 16-bit counter/timers, two fu ll-duplex uarts, 256 bytes of intern al ram, 128 byte special function register (sfr) address space, and bit-addressable i/o ports. 1.1.2. improved throughput the cip-51 employs a pipelined architecture that grea tly increases its instruction throughput over the stan- dard 8051 architecture. in a standa rd 8051, all instructions except for mul and div take 12 or 24 system clock cycles to execute with a maximum system clock of 12-to-24 mhz. by contrast, the cip-51 core exe- cutes 70% of its instructions in one or two system cloc k cycles, with only four in structions taking more than four system clock cycles. the cip-51 has a total of 109 instructions. the table below shows the total number of instructions that require each execution time. with the cip-51's maximum system clock at 25 mhz, it has a peak throughput of 25 mips. figure 1.5 shows a comparison of peak thro ughputs of various 8-bit microcontro ller cores with th eir maximum system clocks. figure 1.5. comparison of peak mcu execution speeds clocks to execute 1 22/333/444/55 8 number of instructions 26505147 3 1 2 1 5 10 15 20 aduc812 8051 (16 mhz clk) philips 80c51 (33 mhz clk) microchip pic17c75x (33 mhz clk) silicon labs cip-51 (25 mhz clk) mips 25
c8051f060/1/2/3/4/5/6/7 26 rev. 1.2 1.1.3. additional features the c8051f06x mcu family includes several key enhancements to the cip-51 core and peripherals to improve overall performance and ease of use in end applications. the extended interrupt handler provides 22 interrupt sources into the cip-51, allowing the numerous ana- log and digital peripherals to interrupt the controller. an interrupt driven system requires less intervention by the mcu, giving it more effective throughput. the extra interrupt sources are very useful when building multi-tasking, real-time systems. there are up to seven reset sources for the mcu: an on-board vdd monitor, a watchdog timer, a missing clock detector, a voltage level detection from compar ator0, a forced software reset, the cnvstr2 input pin, and the /rst pin. the /rst pin is bi-directio nal, accommodating an external reset, or allowing the internally generated por to be output on the /rst pin. each reset source except for the vdd monitor and reset input pin may be disabled by the user in so ftware; the vdd monitor is enabled/disabled via the monen pin. the watchdog timer may be permanently enabled in software after a power-on reset during mcu initialization. the mcu has an internal, stand alone clock generator which is used by default as the system clock after any reset. if desired, the clock sour ce may be switched on the fly to the external oscillator, which can use a crystal, ceramic resonator, capacitor, rc, or external clock source to generate the system clock. this can be extremely useful in low power applications, allowing the mcu to run from a slow (power saving) exter- nal crystal source, while periodically switching to the fast (up to 25 mh z) internal oscillator as needed. figure 1.6. on-board clock and reset wdt xtal1 xtal2 osc internal clock generator system clock cip-51 microcontroller core missing clock detector (one- shot) wdt strobe software reset extended interrupt handler clock select /rst + - vdd supply reset timeout (wired-or) system reset supply monitor pre reset funnel + - cp0+ comparator0 cp0- (port i/o) crossbar cnvstr2 (cnvstr reset enable) (cp0 reset enable) en wdt enable en mcd enable (wired-or) vdd monitor reset enable
c8051f060/1/2/3/4/5/6/7 rev. 1.2 27 1.2. on-chip memory the cip-51 has a standard 8051 program and data addr ess configuration. it includes 256 bytes of data ram, with the upper 128 bytes dual-mapped. indirect addressing accesses the upper 128 bytes of general purpose ram, and direct addressing accesses the 128 byte sfr address space. the cip-51 sfr address space contains up to 256 sfr pages . in this way, the cip-51 mcu can accommodate the many sfrs required to control and configure the various peripherals featured on the device. the lower 128 bytes of ram are accessible via direct and indire ct addressing. the first 32 bytes are addressable as four banks of general purpose registers, and the next 16 bytes can be byte addressable or bit addressable. the cip-51 in the c8051f060/1/2/3/ 4/5/6/7 mcus additionally has an on-chip 4 kb ram block. the on- chip 4 kb block can be addressed over the entire 64 k external data memory address range (overlapping 4 k boundaries). the c8051f060/2/4/6 also have an external memory interfac e (emif) for accessing off- chip data memory or memory-mapped peripherals. external data memory address space can be mapped to on-chip memory only, off-chip memory only, or a co mbination of the two (addresses up to 4 k directed to on-chip, above 4 k directed to emif). the emif is also configurable for multiplexed or non-multiplexed address/data lines. the mcu?s program memory consists of 64 k (c8051f0 60/1/2/3/4/5) or 32 k (c8 051f066/7) of flash. this memory may be reprogrammed in-system in 512 byte sectors, and requires no special off-chip program- ming voltage. on the c8051f060/1/2/3/4/5, th e 1024 bytes from addresses 0xfc00 to 0xffff are reserved. there is also a single 128 byte scratchpad memory sector on all devices which may be used by firmware for non-volatile data storage. se e figure 1.7 for the mcu system memory map. figure 1.7. on-chip memory map program/data memory (flash) (direct and indirect addressing) 0x00 0x7f upper 128 ram (indirect addressing only) 0x80 0xff special function registers (direct addressing only) data memory (ram) general purpose registers 0x1f 0x20 0x2f bit addressable lower 128 ram (direct and indirect addressing) 0x30 internal data address space external data address space xram - 4096 bytes (accessable using movx instruction) 0x0000 0x0fff off-chip xram space (c8051f060/2/4/6 only) 0x1000 0xffff flash (in-system programmable in 512 byte sectors) 0x0000 0xffff reserved 0xfc00 0xfbff scrachpad memory (data only) 0x1007f 0x10000 up to 256 sfr pages 1 3 0 2 c8051f060/1/2/3/4/5 flash (in-system programmable in 512 byte sectors) 0x0000 0xffff reserved 0x8000 0x7fff scrachpad memory (data only) 0x1007f 0x10000 c8051f066/7
c8051f060/1/2/3/4/5/6/7 28 rev. 1.2 1.3. jtag debug and boundary scan the c8051f06x family has on-chip jtag bounda ry scan and debug circ uitry that provides non-intrusive, full speed, in-circuit debugging using the produc tion part installed in the end application , via the four-pin jtag interface. the jtag port is fully compliant to ieee 1 149.1, providing full bounda ry scan for test and manufacturing purposes. silicon laboratories' debugging system supports in spection and modification of memory and registers, breakpoints, watchpoints, a stack monitor, and single stepping. no additional target ram, program mem- ory, timers, or communications channels are required. all the digital and analog peripherals are functional and work correctly while debugging. all the peripher als (except for the adcs and smbus) are stalled when the mcu is halted, during single stepping, or at a breakpoint in order to keep them synchronized with instruction execution. the c8051f060dk development kit provides all the har dware and software necessary to develop applica- tion code and perform in-circuit debugging with t he c8051f06x mcus. the kit includes a windows (95 or later) development environment, a serial adapter for connecting to the jtag port, and a target application board with a c8051f060 mcu installed. all of th e necessary communication cables and a wall-mount power supply are also supplied with the development kit. silicon labs? debug environment is a vastly supe- rior configuration for developing and debugging embedded applications compared to standard mcu emu- lators, which use on-board "ice chips" and target cables and require the mcu in the application board to be socketed. silicon labs' debug environment both incr eases ease of use and pr eserves the performance of the precision, on-chip analog peripherals. figure 1.8. development/in-system debug diagram target pcb serial adapter c8051 f060 jtag (x4), vdd, gnd windows 95 or later silicon labs integrated development environment
c8051f060/1/2/3/4/5/6/7 rev. 1.2 29 1.4. programmable digital i/o and crossbar three standard 8051 ports (0, 1, and 2) are availa ble on the mcus. the c805 1f060/2/4/6 have 4 addi- tional 8-bit ports (3, 5, 6, and 7), and a 3-bit port (port 4) for a total of 59 general-purpose i/o pins. the ports behave like the standard 8051 with a few enhancements. each port pin can be configured as either a push-pull or open-drain output. also, the "weak pull-ups" which are normally fixed on an 8051 can be globally disabl ed, providing additional powe r saving capabilities for low-power applications. perhaps the most unique enhancement is the digital cro ssbar. this is a large digi tal switching network that allows mapping of internal digital system resources to port i/o pins on p0, p1, p2, and p3. (see figure 1.9) unlike microcontrollers with standard mu ltiplexed digital i/o port s, all combinations of functions are supported with all package options offered. the on-chip counter/timers, serial buses, hw interrup ts, comparator outputs, and other digital signals in the controller can be configured to appear on the port i/o pins specified in the crossbar control registers. this allows the user to select the exact mix of general purpose port i/o and digital resources needed for the particular application. figure 1.9. digital crossbar diagram external pins digital crossba r priority decoder smbus 2 spi 4 uart0 2 pca 2 t0, t1, t2, t2ex, t3, t3ex, t4,t4ex, /int0, /int1 p1.0 p1.7 p2.0 p2.7 p0.0 p0.7 highest priority lowest priority 8 8 comptr. outputs (internal digital signals) highest priority lowest priority uart1 6 2 p3.0 p3.7 8 8 p0mdout, p1mdout, p2mdout, p3mdout registers xbr0, xbr1, xbr2, xbr3 p1mdin, p2mdin, p3mdin registers p1 i/o cells p3 i/o cells p0 i/o cells p2 i/o cells 8 port latches p0 p1 p2 8 8 8 p3 8 (p2.0-p2.7) (p1.0-p1.7) (p0.0-p0.7) (p3.0-p3.7) to adc2 input (c8051f060/1/2/3) to comparators /sysclk cnvstr2 c8051f060/2/4/6 only
c8051f060/1/2/3/4/5/6/7 30 rev. 1.2 1.5. programmable counter array the c8051f06x mcu family includes an on-board pr ogrammable counter/timer array (pca) in addition to the five 16-bit general purpose counter/timers. th e pca consists of a dedica ted 16-bit counter/timer time base with 6 programmable capture/compare modul es. the timebase is clocked from one of six sources: the system clock divided by 12, the system clock divided by 4, time r 0 overflow, an external clock input (eci pin), the system clock, or the external oscillator source divided by 8. each capture/compare module can be configured to operate in one of six modes: edge-triggered capture, software timer, high speed output, frequency output, 8-bit pulse width modulator, or 16-bit pulse width modulator. the pca capture/compare module i/o and external clock input are routed to the mcu port i/ o via the digital crossbar. figure 1.10. pca block diagram capture/compare module 1 capture/compare module 0 capture/compare module 2 capture/compare module 3 cex1 eci crossbar cex2 cex3 cex0 port i/o 16-bit counter/timer pca clock mux sysclk/12 sysclk/4 timer 0 overflow eci sysclk external clock/8 capture/compare module 4 cex4 capture/compare module 5 cex5
c8051f060/1/2/3/4/5/6/7 rev. 1.2 31 1.6. controller area network the c8051f060/1/2/3 devices feature a controller ar ea network (can) controller that implements serial communication using the can protoc ol. the can controller facilitates communication on a can network in accordance with the bosch specification 2.0a (bas ic can) and 2.0b (full can). the can controller con- sists of a can core, message ram (separate from the c8051 ram), a message handler state machine, and control registers. the can controller can operate at bit rates up to 1 mbit/second. silicon labs can has 32 message objects each having its own identifier mask used for acceptance filtering of re ceived messages. incoming data, message objects and identifier masks are stored in the can message ram. all protocol functions for transmission of data and acceptance filtering is performed by the can controller and not by the c8051 mcu. in this way, minimal cpu bandwidth is used for can communication. the c8051 configures the can controller, accesses received data, and passes data for transmission via special function registers (sfr) in the c8051. figure 1.11. can controller overview message handler registers message ram (32 message objects) can core tx rx can controller c 8 0 5 1 m c u interrupt s f r 's cantx canrx c8051f060/1/2/3
c8051f060/1/2/3/4/5/6/7 32 rev. 1.2 1.7. serial ports the c8051f06x mcu family includes two enhanced full-duplex uarts, an enhanced spi bus, and smbus/i2c. each of the serial bu ses is fully implemented in hardwar e and makes extensive use of the cip-51's interrupts, thus requiring very little intervention by the cpu. the serial buses do not "share" resources such as timers, interrupts, or port i/o, so any or all of the serial buses may be used together with any other.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 33 1.8. 16-bit analog to digital converters the c8051f060/1/2/3/4 /5/6/7 devices have two on- chip 16-bit sar adcs (adc0 and adc1), which can be used independently in single-ended mode, or to gether in differential mode. adc0 and adc1 can directly access on-chip or external ram, using th e dma interface. with a maximum throughput of 1 msps, the adcs offer 16 bit performance with two availabl e linearity grades. adc0 and adc1 each have the capability to use dedicated, on-chip voltage reference circuitry or an external voltage reference source. the adcs are under full control of the cip-51 microc ontroller via the associated special function regis- ters. the system controller can also put t he adcs into shutdown mode to save power. conversions can be started in four ways; a software command, an overflow of timer 2, an overflow of timer 3, or an external signal inpu t. this flexibility allows the start of conversion to be tr iggered by software events, external hw signals, or a periodic timer over flow signal. the two adcs can operate independently, or be synchronized to perform conversions at the same time. conversion completions are indicated by sta- tus bits, and can generate interrupts. the resulting 16-bit data words are latched into sfrs upon comple- tion of a conversion. a dma interface is also provi ded, which can gather conversions from the adcs, and directly store them to on-chip or external ram. adc0 also contains window compare registers, whic h can be configured to interrupt the controller when adc0 data is within or outside of a specified range. adc0 can monitor a key voltage continuously in back- ground mode, and not interrupt the controller unless the converted data is within the specified window. figure 1.12. 16-bit adc block diagram ain0g ref ain0 start conversion timer 3 overflow timer 2 overflow write to ad1busy cnvstr1 16-bit sar adc0 (dc, -0.2 to 0.6 v) ain1g ref ain1 start conversion 16-bit sar adc1 (dc, -0.2 to 0.6 v) write to ad0busy timer 3 overflow timer 2 overflow write to ad0busy cnvstr0 configuration and control registers dma interface adc0 window compare logic 16 adc data registers 16
c8051f060/1/2/3/4/5/6/7 34 rev. 1.2 1.9. 10-bit analog to digital converter the c8051f060/1/2/3 devices have an on-board 10-bit sar adc (adc2) with a 9-channel input multi- plexer and programmable gain amplifier. this adc f eatures a 200 ksps maximum throughput and true 10- bit performance with an inl of 1lsb. eight input pi ns are available for measurement and can be pro- grammed as single-ended or differential inputs. addi tionally, the on-chip temperature sensor can be used as an input to the adc. the adc is under full control of the cip-51 microcontroller via the special function registers. the adc2 voltage reference is selected between the analog power supply (av+) and the exter- nal vref2 pin. user software may put a dc2 into shutdown mode to save power. a flexible conversion scheduling s ystem allows adc2 conv ersions to be initiated by software commands, timer overflows, or an external input signal. conver sion completions are indicated by a status bit and an interrupt (if enabled), and the resulting 10-bit data word is latched into two sfr locations upon completion. adc2 also contains window compare registers, whic h can be configured to interrupt the controller when adc2 data is within or outside of a specified range. adc2 can monitor a key voltage continuously in back- ground mode, and not interrupt the controller unless the converted data is within the specified window. figure 1.13. 10-bit adc diagram 10 9-to-1 amux ain2.0 ain2.1 ain2.2 ain2.3 ain2.4 ain2.5 ain2.6 ain2.7 configuration and control registers analog multiplexer 10-bit sar adc start conversion timer 3 overflow timer 2 overflow write to ad2busy cnvstr2 input adc data registers conversion complete interrupt vref2 pin av+ vref single-ended or differential measurement temp sensor agnd adc2 window compare logic 10
c8051f060/1/2/3/4/5/6/7 rev. 1.2 35 1.10. 12-bit digital to analog converters the c8051f060/1/2/3 mcus have two integrated 12-bit digital to analog converters (dacs). the mcu data and control interface to each dac is via the special function registers. the mcu can place either or both of the dacs in a low power shutdown mode. the dacs are voltage output mode and include a flex ible output scheduling mechanism. this scheduling mechanism allows dac output updates to be forced by a software write or scheduled on a timer 2, 3, or 4 overflow. the dac voltage reference is supplied from the dedicated vrefd input pin on c8051f060/2 devices or via the vref2 pin on c8051f061/3 devi ces, which is shared with adc2. the dacs are espe- cially useful as references for the comparators or offsets for the differential inputs of the adcs. figure 1.14. dac system block diagram dac0 dac1 vref vref cip-51 and interrupt handler dac0 dac1 sfr's (data and control)
c8051f060/1/2/3/4/5/6/7 36 rev. 1.2 1.11. analog comparators the c8051f060/1/2/3/4/5/6/7 mcus include three an alog comparators on-chip. the comparators have software programmable hysteresis and response time. ea ch comparator can generate an interrupt on its rising edge, falling edge, or both. the interrupts are capable of waking up the mcu from sl eep mode, and comparator 0 can be used as a reset source. the outp ut state of the comparators can be polled in soft- ware or routed to port i/o pins via the crossbar. outputs from the comparator can be routed through the crossbar. the comparators can be programmed to a low power shutdown mode when not in use. figure 1.15. comparator block diagram + - cpn+ cpn- cip-51 and interrupt handler cpn cpn output (port i/o) sfr's (data and control) crossbar 3 comparators comparator inputs port 2.[7:2]
c8051f060/1/2/3/4/5/6/7 rev. 1.2 37 2. absolute maximum ratings table 2.1. absolute maximum ratings * parameter conditions min typ max units ambient temperature under bias -55 125 c storage temperature -65 150 c voltage on any pin (except vdd, av+, avdd, and port 0) with respect to dgnd -0.3 vdd + 0.3 v voltage on any port 0 pin with respect to dgnd. -0.3 5.8 v voltage on vdd, av+, or avdd with respect to dgnd -0.3 4.2 v maximum total current through vdd, av+, avdd, dgnd, and agnd 800 ma maximum output current sunk by any port pin 100 ma maximum output current sunk by any other i/o pin 50 ma maximum output current sourced by any port pin 100 ma maximum output current sourced by any other i/o pin 50 ma * stresses above those listed under ?absolute maxi mum ratings? may cause permanent damage to the device. this is a stress rating only and functional oper ation of the devices at th ose or any other conditions above those indicated in the operation listings of this specification is not imp lied. exposure to maximum rating conditions for extended periods may af fect device reliability.
c8051f060/1/2/3/4/5/6/7 38 rev. 1.2 3. global dc electrical characteristics table 3.1. global dc electrical characteristics -40 to +85 c, 25 mhz system clock unless otherwise specified. parameter conditions min typ max units analog supply voltage (av+, avdd) (note 1) 2.7 3.0 3.6 v digital supply voltage (vdd) 2.7 3.0 3.6 v analog-to-digital supply delta (|vdd - av+| or |vdd - avdd|) 0.5 v supply current from analog peripherals (active) internal ref, adc, dac, com- parators all enabled. (note 2) 14 ma supply current from analog peripherals (inactive) internal ref, adc, dac, com- parators all disabled, oscillator disabled. 0.2 a supply current from cpu and digital peripherals (cpu active) (note 3) vdd=2.7 v, clock=25 mhz vdd=2.7 v, clock=1 mhz vdd=2.7 v, clock=32 khz vdd=3.0 v, clock=25 mhz vdd=3.0 v, clock=1 mhz vdd=3.0 v, clock=32 khz 18 0.7 30 20 1.0 35 ma ma a ma ma a supply current from cpu and digital peripherals (cpu inac- tive, not accessing flash) (note 3) vdd=2.7 v, clock=25 mhz vdd=2.7 v, clock=1 mhz vdd=2.7 v, clock=32 khz vdd=3.0 v, clock=25 mhz vdd=3.0 v, clock=1 mhz vdd=3.0 v, clock=32 khz 13 0.5 20 16 0.8 23 ma ma a ma ma a supply current with all systems shut down oscillator not running 0.2 a vdd supply ram data reten- tion voltage 1.5 v sysclk (system clock) (note 4) 0 25 mhz specified operating tempera- ture range -40 +85 c note 1: analog supply av+ must be greater than 1 v for vdd monitor to operate. note 2: internal oscillato r and vdd monitor current no t included. individual supp ly current contributions for each peripheral are listed in the chapter. note 3: current increases linearly with supply voltage. note 4: sysclk must be at least 32 khz to enable debugging.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 39 4. pinout and package definitions table 4.1. pin definitions name pin numbers type description f060 f061 f064 f065 f062 f063 f066 f067 vdd 37, 64, 90 26, 40, 55 37, 64, 90 26, 40, 55 digital supply voltage. must be tied to +2.7 to +3.6 v. dgnd 38, 63, 89 27, 39, 54 38, 63, 89 27, 39, 54 digital ground. must be tied to ground. av+ 11, 16, 24 7, 10, 18 11, 16, 24 7, 10, 18 analog supply voltage. must be tied to +2.7 to +3.6 v. avdd 13 23 13 23 analog supply voltage. must be tied to +2.7 to +3.6 v. agnd 10, 14, 17, 23 6, 11, 19, 22 10, 14, 17, 23 6, 11, 19, 22 analog ground. must be tied to ground. tms 96 52 96 52 d in jtag test mode select with internal pull-up. tck 97 53 97 53 d in jtag test clock with internal pull-up. tdi 98 56 98 56 d in jtag test data input with internal pull-up. tdi is latched on the rising edge of tck. tdo 99 57 99 57 d out jtag test data outp ut with internal pull-up. data is shifted out on tdo on the falling edge of tck. tdo output is a tri-state driver. /rst 100 58 100 58 d i/o device reset. open-drain output of internal vdd monitor. is driven low when vdd is <2.7 v and monen is high. an external source can initiate a system reset by driving this pin low. xtal1 26 20 26 20 a in crystal input. this pin is the return for the internal oscillator circuit for a cryst al or ceramic resonator. for a precision internal clock, connect a crystal or ceramic resonator from xtal1 to xtal2. if over- driven by an external cmos clock, this becomes the system clock. xtal2 27 21 27 21 a out crystal output. this pin is the excitation driver for a crystal or ceramic resonator. monen 28 63 28 63 d in vdd monitor enable. when tied high, this pin enables the internal vdd monitor, which forces a system reset when vdd is < 2.7 v. when tied low, the internal vdd monitor is disabled. recom- mended configuration is to connect directly to vdd. vref 4 61 4 61 a out bandgap voltage reference output vref0 21 15 21 15 a i/o bandgap voltage reference output for adc0. adc0 voltage reference input.
c8051f060/1/2/3/4/5/6/7 40 rev. 1.2 vrgnd0 20 14 20 14 a in adc0 voltage reference ground. this pin should be grounded if using the adc. vbgap0 22 16 22 16 a out adc0 bandgap bypass pin. vref1 6 2 6 2 a i/o bandgap voltage reference output for adc1. adc1 voltage reference input. vrgnd1 7 3 7 3 a in adc1 voltage refer ence ground. this pin should be grounded if using the adc. vbgap1 5 1 5 1 a out adc1 bandgap bypass pin. vref2 2 a in adc2 voltage reference input. 62 a in adc2, dac0, and dac1 voltage reference input. vrefd 3 a in dac0 and dac1 voltage reference input. ain0 18 12 18 12 a in adc0 signal input (see adc0 specification for complete de scription). ain0g 19 13 19 13 a in adc0 dc bias in put (see adc0 specification for complete de scription). ain1 9 5 9 5 a in adc1 signal input (see adc1 specification for complete de scription). ain1g 8 4 8 4 a in adc1 dc bias input (see adc1 specification for complete de scription). cnvstr0 15 9 15 9 d in external conversion start source for adc0 cnvstr1 12 8 12 8 d in external conversion start source for adc1 cantx 94 59 d out controller area network transmit output. canrx 95 60 d in controller ar ea network receive input. dac0 25 17 a out digital to analog converter 0 voltage output. (see dac specification for co mplete description). dac1 1 64 a out digital to analog converter 1 voltage output. (see dac specification for co mplete description). p0.0 62 51 62 51 d i/o port 0.0. see port input/output section for complete description. p0.1 61 50 61 50 d i/o port 0.1. see port input/output section for complete description. p0.2 60 49 60 49 d i/o port 0.2. see port input/output section for complete description. p0.3 59 48 59 48 d i/o port 0.3. see port input/output section for complete description. p0.4 58 47 58 47 d i/o port 0.4. see port input/output section for complete description. table 4.1. pin definitions (continued) name pin numbers type description f060 f061 f064 f065 f062 f063 f066 f067
c8051f060/1/2/3/4/5/6/7 rev. 1.2 41 p0.5 57 46 57 46 d i/o port 0.5. see port input/output section for complete description. p0.6 56 45 56 45 d i/o port 0.6. see port input/output section for complete description. p0.7 55 44 55 44 d i/o port 0.7. see port input/output section for complete description. p1.0/ain2.0 36 33 36 33 d i/o a in port 1.0. see port input/ou tput section for complete description. adc2 input channel 0 (c8051f060/1/2/3 only). p1.1/ain2.1 35 32 35 32 d i/o a in port 1.1. see port input/ou tput section for complete description. adc2 input channel 1 (c8051f060/1/2/3 only). p1.2/ain2.2 34 31 34 31 d i/o a in port 1.2. see port input/ou tput section for complete description. adc2 input channel 2 (c8051f060/1/2/3 only). p1.3/ain2.3 33 30 33 30 d i/o a in port 1.3. see port input/ou tput section for complete description. adc2 input channel 3 (c8051f060/1/2/3 only). p1.4/ain2.4 32 29 32 29 d i/o a in port 1.4. see port input/ou tput section for complete description. adc2 input channel 4 (c8051f060/1/2/3 only). p1.5/ain2.5 31 28 31 28 d i/o a in port 1.5. see port input/ou tput section for complete description. adc2 input channel 5 (c8051f060/1/2/3 only). p1.6/ain2.6 30 25 30 25 d i/o a in port 1.6. see port input/ou tput section for complete description. adc2 input channel 6 (c8051f060/1/2/3 only). p1.7/ain2.7 29 24 29 24 d i/o a in port 1.7. see port input/ou tput section for complete description. adc2 input channel 7 (c8051f060/1/2/3 only). p2.0 46 43 46 43 d i/o port 2.0. see port input/output section for complete description. p2.1 45 42 45 42 d i/o port 2.1. see port input/output section for complete description. p2.2 44 41 44 41 d i/o port 2.2. see port input/output section for complete description. p2.3 43 38 43 38 d i/o port 2.3. see port input/output section for complete description. p2.4 42 37 42 37 d i/o port 2.4. see port input/output section for complete description. table 4.1. pin definitions (continued) name pin numbers type description f060 f061 f064 f065 f062 f063 f066 f067
c8051f060/1/2/3/4/5/6/7 42 rev. 1.2 p2.5 41 36 41 36 d i/o port 2.5. see port input/output section for complete description. p2.6 40 35 40 35 d i/o port 2.6. see port input/output section for complete description. p2.7 39 34 39 34 d i/o port 2.7. see port input/output section for complete description. p3.0 54 54 d i/o port 3.0. see port i nput/output section for complete description. p3.1 53 53 d i/o port 3.1. see port i nput/output section for complete description. p3.2 52 52 d i/o port 3.2. see port i nput/output section for complete description. p3.3 51 51 d i/o port 3.3. see port i nput/output section for complete description. p3.4 50 50 d i/o port 3.4. see port i nput/output section for complete description. p3.5 49 49 d i/o port 3.5. see port i nput/output section for complete description. p3.6 48 48 d i/o port 3.6. see port i nput/output section for complete description. p3.7 47 47 d i/o port 3.7. see port i nput/output section for complete description. p4.5/ale 93 93 d i/o port 4.5. see port input/output section for complete description. ale strobe for external memory address bus (mul- tiplexed mode). p4.6/rd 92 92 d i/o port 4.6. see port inpu t/output section for complete description. /rd strobe for external memory address bus. p4.7/wr 91 91 d i/o port 4.7. see port inpu t/output section for complete description. /wr strobe for external memory address bus. p5.0/a8 88 88 d i/o port 5.0. see port input/output section for complete description. bit 8 external memory address bus (non-multi- plexed mode). p5.1/a9 87 87 d i/o port 5.1. see port input/output section for complete description. table 4.1. pin definitions (continued) name pin numbers type description f060 f061 f064 f065 f062 f063 f066 f067
c8051f060/1/2/3/4/5/6/7 rev. 1.2 43 p5.2/a10 86 86 d i/o port 5.2. see port input/output section for complete description. p5.3/a11 85 85 d i/o port 5.3. see port input/output section for complete description. p5.4/a12 84 84 d i/o port 5.4. see port input/output section for complete description. p5.5/a13 83 83 d i/o port 5.5. see port input/output section for complete description. p5.6/a14 82 82 d i/o port 5.6. see port input/output section for complete description. p5.7/a15 81 81 d i/o port 5.7. see port input/output section for complete description. p6.0/a8m/ a0 80 80 d i/o port 6.0. see port inpu t/output section for complete description. bit 8 external memory address bus (multiplexed mode). bit 0 external memory address bus (non-multi- plexed mode). p6.1/a9m/ a1 79 79 d i/o port 6.1. see port inpu t/output section for complete description. p6.2/a10m/ a2 78 78 d i/o port 6.2. see port inpu t/output section for complete description. p6.3/a11m/ a3 77 77 d i/o port 6.3. see port inpu t/output section for complete description. p6.4/a12m/ a4 76 76 d i/o port 6.4. see port inpu t/output section for complete description. p6.5/a13m/ a5 75 75 d i/o port 6.5. see port inpu t/output section for complete description. p6.6/a14m/ a6 74 74 d i/o port 6.6. see port inpu t/output section for complete description. p6.7/a15m/ a7 73 73 d i/o port 6.7. see port inpu t/output section for complete description. p7.0/ad0m/ d0 72 72 d i/o port 7.0. see port inpu t/output section for complete description. bit 0 external memory ad dress/data bus (multi- plexed mode). bit 0 external memory da ta bus (non-multiplexed mode). p7.1/ad1m/ d1 71 71 d i/o port 7.1. see port inpu t/output section for complete description. table 4.1. pin definitions (continued) name pin numbers type description f060 f061 f064 f065 f062 f063 f066 f067
c8051f060/1/2/3/4/5/6/7 44 rev. 1.2 p7.2/ad2m/ d2 70 70 d i/o port 7.2. see port inpu t/output section for complete description. p7.3/ad3m/ d3 69 69 d i/o port 7.3. see port inpu t/output section for complete description. p7.4/ad4m/ d4 68 68 d i/o port 7.4. see port inpu t/output section for complete description. p7.5/ad5m/ d5 67 67 d i/o port 7.5. see port inpu t/output section for complete description. p7.6/ad6m/ d6 66 66 d i/o port 7.6. see port inpu t/output section for complete description. p7.7/ad7m/ d7 65 65 d i/o port 7.7. see port inpu t/output section for complete description. nc 1, 2, 3, 25, 94, 95 17, 59, 60, 62, 64 no connection. table 4.1. pin definitions (continued) name pin numbers type description f060 f061 f064 f065 f062 f063 f066 f067
c8051f060/1/2/3/4/5/6/7 rev. 1.2 45 figure 4.1. c8051f060 / c8051f062 pinout diagram (tqfp-100) c8051f060/f062 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 42 43 44 45 46 47 48 49 50 1 2 3 4 5 6 7 8 9 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 75 74 73 72 71 70 69 68 67 p7.6/ad6m/d6 p7.7/ad7m/d7 vdd dgnd p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p3.3 p6.5/a13m/a5 p6.6/a14m/a6 p6.7/a15m/a7 p7.0/ad0m/d0 p7.1/ad1m/d1 p7.2/ad2m/d2 p7.3/ad3m/d3 p7.4/ad4m/d4 p7.5/ad5m/d5 /rst tdo tdi tck tms canrx cantx p4.5/ale p4.6/rd p4.7/wr vdd dgnd p5.0/a8 p5.1/a9 p5.2/a10 p5.3/a11 p5.4/a12 p5.5/a13 p5.6/a14 p5.7/a15 p6.0/a8m/a0 p6.1/a9m/a1 p6.2/a10m/a2 p6.3/a11m/a3 p6.4/a12m/a4 agnd av+ cnvstr1 avdd agnd cnvstr0 av+ agnd ain0 ain0g vrgnd0 vref0 vbgap0 agnd av+ dac0 dac1 vref2 vrefd vref vbgap1 vref1 vrgnd1 ain1g ain1 xtal1 xtal2 monen p1.7/ain2.7 p1.6/ain2.6 p1.5/ain2.5 p1.4/ain2.4 vdd dgnd p1.3/ain2.3 p1.2/ain2.2 p1.1/ain2.1 p1.0/ain2.0 p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 p3.7 p3.6 p3.5 p3.4 p3.2 p3.1 p3.0
c8051f060/1/2/3/4/5/6/7 46 rev. 1.2 figure 4.2. c8051f064 / c8051f066 pinout diagram (tqfp-100) c8051f064/f066 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 42 43 44 45 46 47 48 49 50 1 2 3 4 5 6 7 8 9 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 75 74 73 72 71 70 69 68 67 p7.6/ad6m/d6 p7.7/ad7m/d7 vdd dgnd p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p3.3 p6.5/a13m/a5 p6.6/a14m/a6 p6.7/a15m/a7 p7.0/ad0m/d0 p7.1/ad1m/d1 p7.2/ad2m/d2 p7.3/ad3m/d3 p7.4/ad4m/d4 p7.5/ad5m/d5 /rst tdo tdi tck tms nc nc p4.5/ale p4.6/rd p4.7/wr vdd dgnd p5.0/a8 p5.1/a9 p5.2/a10 p5.3/a11 p5.4/a12 p5.5/a13 p5.6/a14 p5.7/a15 p6.0/a8m/a0 p6.1/a9m/a1 p6.2/a10m/a2 p6.3/a11m/a3 p6.4/a12m/a4 agnd av+ cnvstr1 avdd agnd cnvstr0 av+ agnd ain0 ain0g vrgnd0 vref0 vbgap0 agnd av+ nc nc nc nc vref vbgap1 vref1 vrgnd1 ain1g ain1 xtal1 xtal2 monen p1.7 p1.6 p1.5 p1.4 vdd dgnd p1.3 p1.2 p1.1 p1.0 p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 p3.7 p3.6 p3.5 p3.4 p3.2 p3.1 p3.0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 47 figure 4.3. tqfp-100 package drawing a a1 a2 b d d1 e e e1 l - 0.05 0.95 0.17 - - - - - 0.45 - - 1.00 0.22 16.00 14.00 0.50 16.00 14.00 0.60 1.20 0.15 1.05 0.27 - - - - - 0.75 min (mm) nom (mm) max (mm) 100 e a1 b a2 a pin 1 designator 1 e1 e d1 d l
c8051f060/1/2/3/4/5/6/7 48 rev. 1.2 figure 4.4. c8051f061 / c8051f063 pinout diagram (tqfp-64) c8051f061/063 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 dac1 monen vref2 vref canrx cantx /rst tdo tdi vdd dgnd tck tms p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p2.0 p2.1 p2.2 vdd dgnd p2.3 p2.4 p2.5 p2.6 p2.7 p1.0/ain2.0 vbgap1 vref1 vrgnd1 ain1g ain1 agnd av+ cnvstr1 cnvstr0 av+ agnd ain0 ain0g vrgnd0 vref0 vbgap0 dac0 av+ agnd xtal1 xtal2 agnd avdd p1.7/ain2.7 p1.6/ain2.6 vdd dgnd p1.5/ain2.5 p1.4/ain2.4 p1.3/ain2.3 p1.2/ain2.2 p1.1/ain2.1
c8051f060/1/2/3/4/5/6/7 rev. 1.2 49 figure 4.5. c8051f065 / c8051f067 pinout diagram (tqfp-64) c8051f065/067 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 nc monen nc vref nc nc /rst tdo tdi vdd dgnd tck tms p0.0 p0.1 p0.2 p0.3 p0.4 p0.5 p0.6 p0.7 p2.0 p2.1 p2.2 vdd dgnd p2.3 p2.4 p2.5 p2.6 p2.7 p1.0 vbgap1 vref1 vrgnd1 ain1g ain1 agnd av+ cnvstr1 cnvstr0 av+ agnd ain0 ain0g vrgnd0 vref0 vbgap0 nc av+ agnd xtal1 xtal2 agnd avdd p1.7 p1.6 vdd dgnd p1.5 p1.4 p1.3 p1.2 p1.1
c8051f060/1/2/3/4/5/6/7 50 rev. 1.2 figure 4.6. tqfp-64 package drawing a a1 a2 b d d1 e e e1 l - 0.05 0.95 0.17 - - - - - 0.45 - - - 0.22 12.00 10.00 0.50 12.00 10.00 0.60 1.20 0.15 1.05 0.27 - - - - - 0.75 min (mm) nom (mm) max (mm) 1 64 e e1 e a1 b d d1 pin 1 designator a2 a l
c8051f060/1/2/3/4/5/6/7 rev. 1.2 51 5. 16-bit adcs (adc0 and adc1) the adc subsystem for the c8051f060 /1/2/3/4/5/6/7 consists of two 1 msps, 16-bit successive-approxi- mation-register adcs with integrated track-and-hold , a programmable window detector, and a dma inter- face (see block diagrams in figure 5.1 and figure 5.2). the adcs can be configured as two separate, single-ended adcs, or as a differential pair. t he data conversion modes, window detector, and dma interface are all configurable under software control via the special function registers shown in figure 5.1 and figure 5.2. the voltage references used by adc0 and adc1 are selected as described in section 5.2 . the adcs and their respective track-and-hold circuitr y can be independently enabled or disabled with the special function registers. either adc can be enabl ed by setting the adnen bit in the adc?s control reg- ister (adcncn) to logic 1. the adcs are in low power shutdown when these bits are logic 0. figure 5.1. 16-bit adc0 and adc1 control path diagram ain0g ref 16 av+ ad0en sysclk ain0 start conversion timer 3 overflow timer 2 overflow 00 01 10 11 ad0busy (w) cnvstr0 16-bit sar adc0 adc0cf ad0ocal ad0lcal ad0gcal ad0scal ad0sc0 ad0sc1 ad0sc2 ad0sc3 adc0cn ad0wint ad0cm0 ad0cm1 ad0busy ad0int ad0tm ad0en ref 16 av+ ad1en sysclk ain1 start conversion timer 3 overflow timer 2 overflow ad1busy (w) cnvstr1 16-bit sar adc1 adc1cf ad1ocal ad1lcal ad1gcal ad1scal ad1sc0 ad1sc1 ad1sc2 ad1sc3 adc1cn ad1cm0 ad1cm1 ad1cm2 ad1busy ad1int ad1tm ad1en ad0busy (w) 000 010 100 110 xx1 adc0 data bus adc1 data bus ain1g (dc, -0.2 to 0.6 v) (dc, -0.2 to 0.6 v)
c8051f060/1/2/3/4/5/6/7 52 rev. 1.2 figure 5.2. 16-bit adc0 and adc1 data path diagram 5.1. single-ended or di fferential operation adc0 and adc1 can be programmed to operate i ndependently as single-ended adcs, or together to accept a differential input. in single-ended mode, the adcs can be configured to sample simultaneously, or to use different conversion speeds. in differential mo de, adc1 is a slave to adc0, and its configuration is based on adc0 settings, except during offset or ga in calibrations. the diffsel bit in the channel select register amx0sl (figure 5.6) selects between single-ended and differential mode. 5.1.1. pseudo-differential inputs the inputs to the adcs are pseudo-differential. the ac tual voltage measured by each adc is equal to the voltage between the ainn pin and the ainng pin. ainn g must be a dc signal between -0.2 and 0.6 v. in most systems, ainng will be connected to agnd. if not tied to agnd, the ainng signal can be used to negate a limited amount of fixed offset, but it is recommended that the internal offset calibration features of the device be used for this purpose. when operating in differential mode, ain0g and ain1g should be tied together. ainn must remain above ainng in both modes for accurate conversion results. 16 ain0 16-bit sar adc0 amx0sl diffsel 16 ain1 16-bit sar adc1 adc0h adc0l adc1h adc1l 8 8 0 1 8 8 single-ended differential adc0ltl adc0lth adc0gtl adc0gth 32 16 ad0wint window compare 16 dma interface + - ain0g ain1g
c8051f060/1/2/3/4/5/6/7 rev. 1.2 53 5.2. voltage reference the voltage reference circuitries for adc0 and adc1 allow for many different voltage reference configura- tions. each adc has the capability to use its own dedicat ed, on-chip voltage referenc e, or an of f-chip refer- ence circuit. a block diagram of the reference circuitry for one adc is shown in figure 5.3. the internal voltage reference circuit for each adc consists of an independent, temperature stable 1.2 v bandgap voltage reference generator, with an output buffer amplifier which multiplies the bandgap refer- ence by 2. the maximum load seen by the vrefn (v ref0 or vref1) pin must be less than 100 a to agnd. bypass capacitors of 0.1 f and 47 f are recommended from the vrefn pin to vrgndn. the voltage reference circuitry for each adc is controlled in the reference cont rol registers. ref0cn (defined in figure 5.11) is the reference control regi ster for adc0, and ref1cn (defined in figure 5.12) is the reference control register for adc1. the refncn registers are used to enable/disable the internal reference and bias genera tor circuitry for each adc independently. the biasen bits enable the on-board bias generators for each adc, while the refben bits enable the 2x buffer amplifiers which drive the vrefn pins. when disabled, the supply current drawn by the bandgap and buffer amplifier falls to less than 1 a (typical) and the output of the buffer amplif ier enters a high impedance state (approximately 25 k ohms). if the internal voltage re ference for an adc is used, the bi asen and refben bits for that adc must both be set to logic 1. if an external reference is used, the refben bit should be set to logic 0. note that the biasen bit for an adc must be set to logic 1 to enable that adc, regardless of the voltage refer- ence that is used. if an ad c is not being used, the biasen bit can be set to lo gic 0 to conserve power. the electrical specifications for the volt age references are given in table 5.3. figure 5.3. voltage reference block diagram recommended bypass capacitors x2 adcn ref refncn refben biasen 1.25v band-gap en vbgapn 0.1 f bias vrefn 47 f0.1 f vrgndn external voltage reference
c8051f060/1/2/3/4/5/6/7 54 rev. 1.2 5.3. adc modes of operation adc0 and adc1 have a maximum conv ersion speed of 1 msps. the conv ersion clocks for the adcs are derived from the system clock. the adcnsc bits in the adcncf register determine how many system clocks (from 1 to 16) are used for each conversion clock. 5.3.1. starting a conversion for adc0, conversions can be initiated in one of fo ur ways, depending on the programmed states of the adc0 start of conversion mode bits (ad0cm1, ad 0cm0) in adc0cn. for adc0, conversions may be ini- tiated by: 1. writing a ?1? to the ad0busy bit of adc0cn; 2. a timer 3 overflow (i.e. timed continuous conversions); 3. a rising edge detected on the external adc convert start signal, cnvstr0; 4. a timer 2 overflow (i.e. timed continuous conversions). adc1 conversions can be initiated in five different ways, according to the adc1 start of conversion mode bits (ad1cm2-ad1cm0) in adc1cn. for adc1, conversions may be initiated by: 1. writing a ?1? to the ad1busy bit of adc1cn; 2. a timer 3 overflow (i.e. timed continuous conversions); 3. a rising edge detected on the external adc convert start signal, cnvstr1; 4. a timer 2 overflow (i.e. timed continuous conversions); 5. writing a ?1? to the ad0busy bit of adc0cn. the adnbusy bit is set to logic 1 during conversion and restored to logic 0 when conversion is complete. the falling edge of adnbusy triggers an interrupt (when en abled) and sets the ad nint interrupt flag (adcncn.5). in single-ended mode, the converted data for adcn is available in the adcn data word msb and lsb registers, adcnh, adcnl. in differential mode, the converted data (combined from adc0 and adc1) is available in the adc0 data word msb and lsb registers, adc0h, adc0l. when initiating conversions by wr iting a ?1? to adnbusy, the adnint bit should be polled to determine when a conversion has completed (adcn interrupts may also be us ed). the recommen ded polling proce- dure is shown below. step 1. write a ?0? to adnint; step 2. write a ?1? to adnbusy; step 3. poll adnint for ?1?; step 4. process adcn data. when an external start-of-conversion source is required in differential mode the two pins (cnvstr0 and cnvstr1) should be tied together. 5.3.2. tracking modes the adntm bit in register adcncn controls the ad cn track-and-hold mode. when the adc is enabled, the adc input is continuously tracked when a conversi on is not in progress. when the adntm bit is logic 1, each conversion is preceded by a tracking period (after the start-of-conversion signal). when the cnvstrn signal is used to initiate conversions, t he adc will track until a risi ng edge occurs on the cnvstrn pin (see figure 5.4 and table 5.1 for conver sion timing parameters). setting adntm to 1 can be useful to ensure that settling time requirements are met when an external multiplexer is used on the analog input (see section ?5.3.3. settling time requirements? on page 56 ).
c8051f060/1/2/3/4/5/6/7 rev. 1.2 55 figure 5.4. adc track and c onversion example timing table 5.1. conversion timing (t conv ) adnsc3-0 adcntm = 0 adcntm = 1 adnsc3-0 adcntm = 0 adcntm = 1 0000 21*t sysclk 38*t sysclk 1000 171*t sysclk 315*t sysclk 0001 40*t sysclk 72*t sysclk 1001 189*t sysclk 349*t sysclk 0010 58*t sysclk 106*t sysclk 1010 208*t sysclk 384*t sysclk 0011 78*t sysclk 142*t sysclk 1011 226*t sysclk 418*t sysclk 0100 97*t sysclk 177*t sysclk 1100 245*t sysclk 453*t sysclk 0101 115*t sysclk 211*t sysclk 1101 263*t sysclk 487*t sysclk 0110 134*t sysclk 246*t sysclk 1110 282*t sysclk 522*t sysclk 0111 152*t sysclk 280*t sysclk 1111 300*t sysclk 556*t sysclk cnvstrn timer 2, timer 3 overflow; write '1' to adnbusy adcntm=1 adcntm=0 a. adc timing for external trigger source b. adc timing for internal trigger sources track convert track track track convert track track convert track t conv t conv t conv
c8051f060/1/2/3/4/5/6/7 56 rev. 1.2 5.3.3. settling time requirements the adc requires a minimum tracking time before an accurate conversion can be performed. this tracking time is determined by the adc inpu t resistance, the adc sampling capaci tance, any external source resis- tance, and the accuracy required for the conversion. figure 5.5 shows the equivalent adc input circuits for both differential and single-ended modes. notice that the equivalent time constant for both input circuits is the same. the required settling time for a given settling accuracy ( sa ) may be approximated by equation 5.1. an absolute minimum tracking time of 280 ns is required prior to the start of a conversion. equation 5.1. adc0 settling time requirements where: sa is the settling accuracy, given as a fraction of an lsb (for example, 0.25 to settle within 1/4 lsb) t is the required settling time in seconds r total is the sum of the adc input resistance and any external source resistance. n is the adc resolution in bits (16). figure 5.5. adc0 and adc1 equivalent input circuits t 2 n sa ------ - ?? ?? r total c sample ln = r ain = 30 ? rc input = r ain * c sample r ain = 30 ? c sample = 80pf c sample = 80pf differential mode ain0 ain1 r ain = 30 ? c sample = 80pf rc input = r ain * c sample single-ended mode ain0 or ain1
c8051f060/1/2/3/4/5/6/7 rev. 1.2 57 figure 5.6. amx0sl: amux configuration register bit 7: reserved. write to 0b. bit 6: diffsel: fully differential conversion mode select bit. 0: operate in single-ended mode. 1: operate in differential mode. bit 5-0: reserved. write to 000000b. note: for single-ended mode, the adc0 data word is stored in adc0h and adc0l, while the adc1 data word is stored in adc1h and adc1l. in differential mode, the combined adc data wo rd is stored in adc0h and adc0l, and is a 2?s complement number. adc1?s data word (single-ended) is also stored in adc1h and adc1l. r/w r/w r/w r/w r/w r/w r/w r/w reset value - diffsel - - - - - - 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xbb 0
c8051f060/1/2/3/4/5/6/7 58 rev. 1.2 figure 5.7. adc0cf: adc0 configuration register bits 7-4: ad0sc3-0: adc0 sar co nversion clock period bits. sar conversion clock is divided down from the system clock according to the ad0sc bits (ad0sc3-0). the number of system clocks used for each sar conversion clock is equal to ad0sc + 1. (note: the adc0 sar conversion clock should be less than or equal to 25 mhz). see table 5.1 for conversion timing details. bit 3: ad0scal: system calibration enable. 0: internal ground and reference voltage are used during offset and gain calibration. 1: external voltages can be used during offset and gain calibration. bit 2: ad0gcal: gain calibration. read: 0: gain calibration is completed or not yet started. 1: gain calibration is in progress. write: 0: no effect. 1: initiates a gain calibra tion if adc0 is idle. bit 1: ad0lcal: linearity calibration read 0: linearity calibration is completed or not yet started 1: linearity calibration is in progress write 0: no effect 1: initiates a linearity ca libration if adc0 is idle bit 0: ad0ocal: offset calibration. read: 0: offset calibration is completed or not yet started. 1: offset calibration is in progress. write: 0: no effect. 1: initiates an offset calib ration if adc0 is idle. r/w r/w r/w r/w r/w r/w r/w r/w reset value ad0sc3 ad0sc2 ad0sc1 ad0sc0 ad0scal ad0gcal ad0lcal ad0ocal 11110000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xbc 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 59 figure 5.8. adc1cf: adc1 configuration register bits 7-4: ad1sc3-0: adc1 sar co nversion clock period bits. sar conversion clock is divided down from the system clock according to the ad1sc bits (ad1sc3-0). the number of system clocks used for each sar conversion clock is equal to ad1sc + 1. (note: the adc1 sar conversion clock should be less than or equal to 25 mhz). see table 5.1 for conversion timing details. bit 3: ad1scal: system calibration enable. 0: internal ground and reference voltage are used for offset and gain calibration. 1: external voltages can be used for offset and gain calibration. bit 2: ad1gcal: gain calibration. read: 0: gain calibration is completed or not yet started. 1: gain calibration is in progress. write: 0: no effect. 1: initiates a gain calibra tion if adc1 is idle. bit 1: ad1lcal: linearity calibration read 0: linearity calibration is completed or not yet started 1: linearity calibration is in progress write 0: no effect 1: initiates a linearity ca libration if adc1 is idle bit 0: ad1ocal: offset calibration. read: 0: offset calibration is completed or not yet started. 1: offset calibration is in progress. write: 0: no effect. 1: initiates an offset calib ration if adc1 is idle. r/w r/w r/w r/w r/w r/w r/w r/w reset value ad1sc3 ad1sc2 ad1sc1 ad1sc0 ad1scal ad1gcal ad1lcal ad1ocal 11110000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xbc 1
c8051f060/1/2/3/4/5/6/7 60 rev. 1.2 figure 5.9. adc0cn: adc0 control register bit 7: ad0en: adc0 enable bit. 0: adc0 disabled. adc0 is in low-power shutdown. 1: adc0 enabled. adc0 is active and ready for data conversions or calibrations. bit 6: ad0tm: adc track mode bit. 0: when the adc is enabled, tracking is co ntinuous unless a conversion is in process. 1: tracking defined by ad0cm1-0 bits. bit 5: ad0int: adc0 conversion complete interrupt flag. this flag must be cleared by software. 0: adc0 has not completed a data conversion since the last time this flag was cleared. 1: adc0 has completed a data conversion. bit 4: ad0busy: adc0 busy bit. read: 0: adc0 conversion is complete or a conversion is not currently in progress. ad0int is set to logic 1 on the falling edge of ad0busy. 1: adc0 conversion is in progress. write: 0: no effect. 1: initiates adc0 conversion if ad0cm1-0 = 00b. bits 3-2: ad0cm1-0: adc0 start of conversion mode select. if ad0tm = 0: 00: adc0 conversion initiated on every write of ?1? to ad0busy. 01: adc0 conversion initiated on overflow of timer 3. 10: adc0 conversion initiated on rising edge of external cnvstr0. 11: adc0 conversion initiated on overflow of timer 2. if ad0tm = 1: 00: tracking starts with the write of ?1? to ad0busy and is followed by the conversion. 01: tracking started by the overflow of timer 3 and is followed by the conversion. 10: adc0 conversion starts on rising cnvstr0 edge. 11: tracking started by the overflow of timer 2 and is followed by the conversion. see figure 5.4 and table 5.1 for conversion timing parameters. bit 1: ad0wint: adc0 windo w compare interrupt flag. this bit must be cleared by software. 0: adc0 window comparison data match has no t occurred since this flag was last cleared. 1: adc0 window comparison data match has occurred. bit 0: reserved: write to 0b. r/w r/w r/w r/w r/w r/w r/w r/w reset value ad0en ad0tm ad0int ad0busy ad0cm1 ad0cm0 ad0wint - 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xe8 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 61 figure 5.10. adc1cn: adc1 control register bit 7: ad1en: adc1 enable bit. 0: adc1 disabled. adc1 is in low-power shutdown. 1: adc1 enabled. adc1 is active and ready for data conversions or calibrations. bit 6: ad1tm: adc track mode bit. 0: when the adc is enabled, tracking is co ntinuous unless a conversion is in process. 1: tracking defined by ad1cm2-0 bits. bit 5: ad1int: adc1 conversion complete interrupt flag. this flag must be cleared by software. 0: adc1 has not completed a data conversion since the last time this flag was cleared. 1: adc1 has completed a data conversion. bit 4: ad1busy: adc1 busy bit. read: 0: adc1 conversion is complete or a conversion is not currently in progress. ad1int is set to logic 1 on the falling edge of ad1busy. 1: adc1 conversion is in progress. write: 0: no effect. 1: initiates adc1 conversion if ad1cm2-0 = 000b. bits 3-1: ad1cm2-0: adc1 start of conversion mode select. if ad1tm = 0: 000: adc1 conversion initiated on every write of ?1? to ad1busy. 010: adc1 conversion initiated on overflow of timer 3. 100: adc1 conversion initiated on rising edge of external cnvstr1. 110: adc1 conversion initiated on overflow of timer 2. xx1: adc1 conversion initiated on every write of ?1? to ad0busy in adc0cn if ad1tm = 1: 000: tracking starts with the write of ?1? to ad1busy and is followed by the conversion. 010: tracking started by the overflow of timer 3 and is followed by the conversion. 100: adc1 conversion starts on rising cnvstr1 edge. 110: tracking started by the overflow of timer 2 and is followed by the conversion. xx1: tracking starts with the write of ?1? to ad0busy and is followed by the conversion. see figure 5.4 and table 5.1 for conversion timing parameters. bit 0: reserved: write to 0b. r/w r/w r/w r/w r/w r/w r/w r/w reset value ad1en ad1tm ad1int ad1busy ad1cm2 ad1cm1 ad1cm0 - 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xe8 1
c8051f060/1/2/3/4/5/6/7 62 rev. 1.2 figure 5.11. ref0cn: refere nce control register 0 bits7-2: reserved. read = 000000b; write = 000000b. bit1: biase0: adc0 bias generator enab le bit. (must be ?1? if using adc0). 0: adc0 internal bias generator off. 1: adc0 internal bias generator on. bit0: refbe0: internal reference buffer for adc0 enable bit. 0: internal reference buffer for adc0 of f. external voltage reference can be used. 1: internal reference buffer for adc0 on. internal voltage reference is driven on the vref0 pin. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - - - biase0 refbe0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd1 0 figure 5.12. ref1cn: reference control register 1 bits7-2: reserved. read = 000000b; write = 000000b. bit1: biase1: adc1 bias generator enab le bit. (must be ?1? if using adc1). 0: adc1 internal bias generator off. 1: adc1 internal bias generator on. bit0: refbe1: internal reference buffer for adc1 enable bit. 0: internal reference buffer for adc1 of f. external voltage reference can be used. 1: internal reference buffer for adc1 on. internal voltage reference is driven on the vref1 pin. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - - - biase1 refbe1 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd1 1
c8051f060/1/2/3/4/5/6/7 rev. 1.2 63 figure 5.13. adc0h: adc0 data word msb register bits 7-0: adc0 data word high-order bits. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xbf 0 figure 5.14. adc0l: adc0 da ta word lsb register bits 7-0: adc0 data word low-order bits. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xbe 0
c8051f060/1/2/3/4/5/6/7 64 rev. 1.2 16-bit adc0 data word appears in the adc0 data word registers as follows: example: adc0 data word conversion map, ain0 input in single-ended mode (amx0sl = 0x00) example: adc0 data word conversion map, ain0-ain1 diffe rential input pair (amx0sl = 0x40) ; ?n? = 16 for single-ended; ?n?=15 for differential. ain0-ain0g (volts) adc0h:adc0l vref * (65535/65536) 0xffff vref / 2 0x8000 vref * (32767/65536) 0x7fff 0 0x0000 ain0-ain1 (volts) adc0h:adc0l vref * (32767/32768) 0x7fff vref / 2 0x4000 vref * (1/32768) 0x0001 0 0x0000 -vref * (1/32768) 0xffff -vref / 2 0xc000 -vref 0x8000 code vin gain vref --------------- 2 n = figure 5.15. adc0 data word example
c8051f060/1/2/3/4/5/6/7 rev. 1.2 65 figure 5.16. adc1h: adc1 data word msb register bits 7-0: adc1 data word high-order bits. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xbf 1 figure 5.17. adc1l: adc1 da ta word lsb register bits 7-0: adc1 data word low-order bits. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xbe 1 figure 5.18. adc1 data word example 16-bit adc1 data word appears in the adc1 data word registers as follows: example: adc1 data word conversion map, ain1 input in single-ended mode (amx1sl = 0x00) ; ?n? = 16 for differential mode, the differential data word appears in adc0h and adc0l. the single- ended adc1 results are always present in adc1h and adc1l, regardless of the operating mode. ain1-ain1g (volts) adc1h:adc1l vref * (65535/65536) 0xffff vref / 2 0x8000 vref * (32767/65536) 0x7fff 00x0000 code vin gain vref --------------- 2 n =
c8051f060/1/2/3/4/5/6/7 66 rev. 1.2 5.4. calibration the adcs are calibrated for linearity, offset, and gain in production. adc0 and adc1 can also be indepen- dently calibrated for each of these parameters in-system. ca librations are initiated using bits in the adc0 or adc1 configuration register. the calibration coefficients can be accessed using the adc calibration pointer register (adc0cpt, figu re 5.22) and the adc calibration coefficient register (adc0ccf, figure 5.23). the cptr bits in adc0cpt allow the ad c0ccf register to read and write specific calibra- tion coefficients. figure 5.19 shows the calibration coefficient locations. the adcs are calibrated for linearity in production. under normal circumstances, no additional linearity calibration is necessary. if linearity calibrations are de sired, they can be initiated by setting the adcnlcal bit to ?1?. when the calibration is finished, the adcnlcal bit will be se t to ?0? by the hardware. linearity calibration coefficients are stored in the locations shown in figure 5.19. offset and gain calibrations can be performed using ei ther internal or external voltages as calibration sources. the adcnscal bit determines whether the in ternal or external voltages are used in the calibra- tion process. to ensure accuracy, offset calibration should be done prior to a gain calibration. the offset and gain calibration coefficients are decoded in figur e 5.20. offset calibration is initiated by setting the adcnocal bit to ?1?. when the calib ration is finished, the adcnocal bi t will be set to ?0? by the hardware. offset calibration can compensate for offset errors of approximately 3.125% of full scale. the offset value is added to the ainng input prior to digitization by t he adc. gain calibration is in itiated by setting the adc- ngcal bit to ?1?. when the calibration is finished, the adcngcal bit will be set to ?0? by the hardware. gain calibration can compensate for slope errors of approximately 3.125%. the gain value is added to the adc?s vref path to change the slope of the conv erter?s transfer function. figure 5.21 shows how the offset and gain values affect th e analog signals used by the adc. figure 5.19. calibration coefficient locations adc0ccf adc0cpt bits 5-0 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 0x00 linearity calibration coefficients (locations 0x00 through 0x12) . . 0x12 0x13 offset7 offset6 offset5 offset4 offset3 offset2 offset1 offset0 0x14 offset13 offset12 offset11 offset10 offset9 offset8 0x15 gain7 gain6 gain5 gain4 gain3 gain2 gain1 gain0 0x16 gain12 gain11 gain10 gain9 gain8
c8051f060/1/2/3/4/5/6/7 rev. 1.2 67 the offset register value affects the offset at the analog input as follows: the gain register value affects the slope of the adc transfer fu nction as follows: offset register (14 bits) approximate offset change (v) 0x3fff -3.125% * vref 0x2000 0 0x0000 +3.125% * vref gain register (13 bits) approximate slope change 0x1fff +3.125% 0x1000 0 0x0000 -3.125% offset change 0x2000 offset register ? 8192 ------------------------------------------------------------ 3.125% vref ? slope change gain register 0x1000 ? 4096 -------------------------------------------------------- - 3.125% ? figure 5.20. offset and gain register mapping ainn adcn offset + vref gain adcn data 16 ainng - + figure 5.21. offset and gain calibration block diagram
c8051f060/1/2/3/4/5/6/7 68 rev. 1.2 figure 5.22. adc0cpt: adc calibration pointer register bit 7: incr: pointer addr ess automatic increment. 0: disable auto-increment. 1: enable auto-incre ment. cptr5-0 will automat ically be incremented after each read or write to adc0ccf. bit 6: adcsel: adc calibration coefficient select. 0: reads and writes of adc0ccf will access adc0 calibration coefficients. 1: reads and writes of adc0ccf will access adc1 calibration coefficients. bits 5-0: cptr5-0: calibration coefficent pointer. select which calibration coefficient location will be accessed when adc0ccf is read or written. r/w r/w r/w r/w r/w r/w r/w r/w reset value incr adcsel cptr5 cptr4 cptr3 cptr2 cptr1 cptr0 11010111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xba f figure 5.23. adc0ccf: adc calibration coefficient register bits 7-0: calibration coefficients at the lo cation specified in a dc0cpt. see table 5.19. r/w r/w r/w r/w r/w r/w r/w r/w reset value variable bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xbb f
c8051f060/1/2/3/4/5/6/7 rev. 1.2 69 5.5. adc0 programmable window detector the adc0 programmable window detector continuousl y compares the adc0 output to user-programmed limits, and notifies the system when an out-of-bound condi tion is detected. this is especially effective in an interrupt-driven system, saving code space and cpu bandwidth while delivering faster system response times. the window detector interrupt flag (ad0wint in adc0cn) can also be used in polled mode. the high and low bytes of the reference words are loaded into the adc0 greater-than and adc0 less-than registers (adc0gth, adc0gtl, adc0lth, and adc0lt l). the window detector can be used in single- ended or differential mode. in signle-ended mode, the window detector compares the adc0gtx and adc0ltx registers to the output of adc0. in differ ential mode, the combined output of adc0 and adc1 (contained in the adc0 data registers) is used for the comparison. reference comparisons are shown starting on page 71. notice that the window detect or flag can be asserted when the measured data is inside or outside the user-programmed limits, depending on the programming of the adc0gtx and adc0ltx registers. figure 5.24. adc0gth: adc0 greater- than data high byte register bits 7-0: high byte of adc0 greater-than data word. r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc5 0 figure 5.25. adc0gtl: adc0 greater-than data low byte register bits 7-0: low byte of adc0 greater-than data word. r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc4 0
c8051f060/1/2/3/4/5/6/7 70 rev. 1.2 bits 7-0: high byte of adc0 less-than data word. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc7 0 figure 5.26. adc0lth: a dc0 less-than data high byte register figure 5.27. adc0ltl: adc0 less- than data low byte register bits 7-0: low byte of adc0 less-than data word. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc6 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 71 figure 5.28. 16-bit adc0 window inte rrupt example: single-ended data given: amx0sl = 0x00, adc0lth:adc0ltl = 0x2000, adc0gth:adc0gtl = 0x1000. an adc0 end of conversion will cause an adc0 window compare interrupt (ad0wint = ?1?) if the resulti ng adc0 data word is < 0x2000 and > 0x1000. given: amx0sl = 0x00, adc0lth:adc0ltl = 0x1000, adc0gth:adc0gtl = 0x2000. an adc0 end of conv ersion will cause an adc0 window compare interrupt (ad0wint = ?1?) if the resultin g adc0 data word is > 0x2000 or < 0x1000. 0xffff 0x2001 0x2000 0x1fff 0x1001 0x1000 0x0fff 0x0000 ad0wint=1 ad0wint not affected ad0wint not affected adc0 data word 0xffff 0x2001 0x2000 0x1fff 0x1001 0x1000 0x0fff 0x0000 ad0wint=1 ad0wint not affected ad0wint=1 adc0lth:adc0ltl adc0gth:adc0gtl adc0 data word adc0gth:adc0gtl adc0lth:adc0ltl 0 input voltage (ain0 - ain0g) ref x (65535/65536) ref x (4096/65536) ref x (8192/65536) 0 input voltage (ain0 - ain0g) ref x (65535/65536) ref x (4096/65536) ref x (8192/65536)
c8051f060/1/2/3/4/5/6/7 72 rev. 1.2 0x7fff 0x1001 0x1000 0x0fff 0x0000 0xffff 0xfffe 0x8000 ad0wint=1 ad0wint not affected ad0wint not affected 0x7fff 0x1001 0x1000 0x0fff 0x0000 0xffff 0xfffe 0x8000 ad0wint=1 ad0wint not affected input voltage (ain0 - ain1) ad0wint=1 adc0lth:adc0ltl adc0gth:adc0gtl adc0 data word adc0 data word adc0lth:adc0ltl adc0gth:adc0gtl -ref input voltage (ain0 - ain1) ref x (32767/32768) ref x (4096/32768) ref x (-1/32768) -ref ref x (32767/32768) ref x (4096/32768) ref x (-1/32768) figure 5.29. 16-bit adc0 window interr upt example: differential data given: amx0sl = 0x40, adc0lth:adc0ltl = 0x1000, adc0gth:adc0gtl = 0xffff. an adc0 end of conversion will cause an adc0 window compare interrupt (ad0wint = ?1?) if the resulti ng adc0 data word is < 0x1000 and > 0xffff. (in two?s-complement math, 0xffff = -1.) given: amx0sl = 0x40, adc0lth:adc0ltl = 0xffff, adc0gth:adc0gtl = 0x1000. an adc0 end of conversion will cause an adc0 window compare interrupt (ad0wint = ?1?) if the resultin g adc0 data word is < 0xffff or > 0x1000. (in two?s-complement math, 0xffff = -1.)
c8051f060/1/2/3/4/5/6/7 rev. 1.2 73 table 5.2. 16-bit adc0 and adc1 electrical characteristics vdd = 3.0 v, av+ = 3.0 v, avdd = 3.0 v, vref = 2. 50 v (refbe=0), -40 to +85 c unless otherwise specified parameter conditions min typ max units dc accuracy resolution 16 bits integral nonlinearity (c8051f060/1/4/5/6/7) single-ended differential 0.75 0.5 2 1 lsb integral nonlinearity (c8051f062/3) single-ended differential 1.5 1 4 2 lsb differential nonlinearity gu aranteed monotonic 0.5 lsb offset error 0.1 mv full scale error 0.008 %f.s. gain temperature coefficient 0.5 ppm/c dynamic performance (sampling ra te = 1 msps, avdd, av+ = 3.3v) signal-to-noise plus distorti on fin = 10 khz, single-ended fin = 100 khz, single-ended fin = 10 khz, differential fin = 100 khz, differential 86 84 89 88 db db db db total harmonic distortion fin = 10 khz, single-ended fin = 100 khz, single-ended fin = 10 khz, differential fin = 100 khz, differential 96 84 103 93 db db db db spurious-free dynamic range fin = 10 khz, single-ended fin = 100 khz, single-ended fin = 10 khz, differential fin = 100 khz, differential 97 88 104 99 db db db db cmrr fin = 10 khz 86 db channel isolation 100 db timing sar clock frequency 25 mhz conversion time in sar clocks 18 clocks track/hold acquisition time 280 ns throughput rate 1 msps aperture delay external cnvst signal 1.5 ns rms aperture jitter external cnvst signal 5 ps analog inputs input voltage range single-ended (ainn - ainng) differential (ain0 - ain1) 0 -vref vref vref v v input capacitance 80 pf
c8051f060/1/2/3/4/5/6/7 74 rev. 1.2 operating input range ain0 or ain1 ain0g or ain1g (dc only) -0.2 -0.2 av+ 0.6 v v power specifications power supply current (each adc) operating mode, 1 msps av+ avdd shutdown mode 4.0 2.0 <1 ma ma a power supply rejection vdd 5% 0.5 lsb table 5.3. voltage reference 0 and 1 electrical characteristics vdd = 3.0 v, av+ = 3.0 v, avdd = 3.0 v, -40 to +85 c unless otherwise specified parameter conditions min typ max units internal reference output voltage 25 c ambient 2.36 2.43 2.48 v vref temperature coefficient 15 ppm/c power supply current (each voltage reference) av+ 1.5 ma external reference input voltage range 2.0 av+ v input current adc throughput = 1 msps 450 a table 5.2. 16-bit adc0 and adc1 electrical characteristics (continued) vdd = 3.0 v, av+ = 3.0 v, avdd = 3.0 v, vref = 2. 50 v (refbe=0), -40 to +85 c unless otherwise specified parameter conditions min typ max units
c8051f060/1/2/3/4/5/6/7 rev. 1.2 75 6. direct memory access interface (dma0) the dma interface works in conjunct ion with adc0 and adc1 to write ad c outputs directly to a specified region of xram. the dma interface is configured by so ftware using the special function registers shown in figure 6.1. up to 64 instructions can be programm ed into the instruction buffer to designate a sequence of dma operations. the instruction buffer is accessed by the dma control logic, which gathers the appro- priate data from the adcs and controls writes to xram. the dma inst ructions tell the dma control logic which adc(s) to expect results from, bu t do not initiate the actual conversions. it is important to configure the adcs for the desired start-of-conversion source, voltage reference, and sar clock frequency prior to starting the dma interface. for information on setting up the adcs, refer to section ?5. 16-bit adcs (adc0 and adc1)? on page 51 . 6.1. writing to the instruction buffer the instruction buffer has 64 8-bit locations that can be programmed with a sequence of dma instructions. filling the instruction buffer is done with the sp ecial function registers dma0 ipt (dma instruction write address register, figure 6.6) and dma0idt (dma inst ruction write data register, figure 6.7). instruc- tions are written to the instruction buffer at address dma0ipt when the instruction word is written to dma0idt. reading the register dma0id t will return the instruction word at location dma0ipt. after a write or read operation on dma0idt, the dma0ipt register is automatically incremente d to the next instruction buffer location. ain0 adc0 ain1 adc1 dma control logic dma0idt instruction data dma0ipt address write logic dma0bnd start address instruction buffer (64 bytes) adc0en adc1en diffsel ccnv dma0isw current address xram (on-chip or off-chip) dma0dsh current xram address dma0dsl dma0dah beginning xram address dma0dal dma0csh current repeat counter value dma0csl dma0cth repeat counter limit dma0ctl address bus data bus dma0cf dma0eo dma0eoe dma0ci dma0cie dma0xby dma0hlt dma0cn dma0do0 dma0do1 dma0doe dma0de0 dma0de1 dma0md dma0int dma0en ain0g ain1g figure 6.1. dma0 block diagram
c8051f060/1/2/3/4/5/6/7 76 rev. 1.2 6.2. dma0 instruction format dma instructions can request single-ended data from both adc0 and adc1, as well as the differential combination of the two adc inputs. the instruction fo rmat is identical to the dma0idt register, shown in figure 6.7. depending on which bits ar e set to ?1? in the instruction word , either 2 or 4 bytes of data will be written to xram for each dma in struction cycle (excluding end-of -operation instructions). table 6.1 details all of the valid dma instruct ions. instructions not listed in the table are not valid dma instructions, and should not be used. note that the adcs can be independently controlled by the microcontroller when their outputs are not requested by the dma. 6.3. xram addressing and setup the dma interface can be configured to access either on-chip or off-chip xram. any writes to on-chip xram by the dma control logic occur when the proc essor core is not accessi ng the on-chip xram. this ensures that the dma will not interfere with proces sor instruction timing. off-chip xram access (only available on the c8 051f060/2/4/6) is controlled by the dma0hlt bit in dma0cf (dma configuratio n register, figure 6.5). th e dma will have full access to off-chip xram when this bit is ?0?, and the processor core will have full access to off-chip xram wh en this bit is ?1?. the dma0hlt bit should be controlled in software when both the processor core and the dma interface require access to off-chip xram data space. before setting dma0hlt to ?1?, the software should check the dma0xby bit to ensure that the dma is not currently accessing of f-chip xram. the pr ocessor core can- not access off-chip xram wh ile dma0hlt is ?0?. the processor will cont inue as though it was able to per- form the desired memory access, but the data will not be written to or read from off-chip xram. when the processor core is finished acce ssing off-chip xram, dma0hlt shoul d be set back to ?0?in software to return control to the dma interfac e. the dma control logic will wait un til dma0hlt is ?0? before writing data to off-chip xram. if new data becomes available to the dma interface before the previous data has been written, an overflow condition will oc cur, and the new data word may be lost. the data address pointer registers (dma0dsh and dma0dsl) contain the 16-bit xram address loca- tion where the dma interface will wr ite data. when the dma is initially enabled, the dma data address table 6.1. dma0 instruction set instruction word description first data written to xram (2 bytes) second data written to xram (2 bytes) 00000000b end-of-operation none none 10000000b end-of-operation with continuous conversion none none x0010000b retrieve adc0 data adc0h:adc0l none x0100000b retrieve adc1 data adc1h:adc1l none x0110000b retrieve adc0 and adc1 data adc0h:adc0l adc1h:adc1l x10x0000b retrieve differential data adc0h:adc0l (differential result from both adcs) none x11x0000b retrieve differential and adc1 data adc0h:adc0l (differential result from both adcs) adc1h:adc1l
c8051f060/1/2/3/4/5/6/7 rev. 1.2 77 pointer registers are initialized to the values contained in the dma data address beginning registers (dma0dah and dma0dal). the data address pointer re gisters are automatically incremented by 2 or 4 after each data write by the dma interface. 6.4. instruction execution in mode 0 when the dma interface begins an operation cycle , the dma instruction status register (dma0isw, figure 6.9) is loaded with the address contained in the dma instruction boundary register (dma0bnd, figure 6.8). the instruction is fetched from the instruction buffer, and the dma control logic waits for data from the appropriate adc(s). the dma will execute each instruction once, and then increment dma0isw to the next instruction address. when the current dma instruction is an end of operation instruction, the instruction status register is reset to the instruct ion boundary register. if the continuous conversion bit (bit 7, ccnv) in the end of operatio n instruction word is set to ?1?, the repeat counter is ignored, and the dma will continue to execute instructio ns indefinitely. when ccnv is set to ?0?, the repeat counter (regis- ters dma0csh and dma0csl) is decr emented, and the dma w ill continue to execute instructions until the repeat counter reaches 0x0000. the repeat counter is initialized with the repeat counter limit value (registers dma0cth and dma0ctl) at the begi nning of the dma operation. an example of mode 0 operation is shown in figure 6.2. 00000000 0x3f 00110000 00010000 01000000 0x01 0x02 0x03 ... 0x00 adc0h adc0l dma0bnd adc0h adc0l dma0csh:l = dma0cth:l dma0csh:l = dma0cth:l - 1 dma0csh:l = 0x0000 instruction buffer (64 bytes) xram adc0h (diff.) adc0l adc0h (diff.) adc0l (diff.) adc0h adc0l adc1h adc1l adc1h adc1l figure 6.2. dma mode 0 operation
c8051f060/1/2/3/4/5/6/7 78 rev. 1.2 6.5. instruction execution in mode 1 when the dma interface begins an operation cycle , the dma instruction status register (dma0isw, figure 6.9) is loaded with the address containe d within the dma instruction boundary register (dma0bnd, figure 6.8). the instruction is fetched from the instruction buffer, and the dma control logic waits for data from the appropriate adc(s). at the end of an instruction, the repeat counter (registers dma0csh and dma0csl) is decremen ted, and the instruction will be r epeated until th e repeat counter reaches 0x0000. the repeat counter is then rese t to the repeat counter limit value (registers dma0cth and dma0ctl), and the dm a will increment dma0isw to the ne xt instruction address. when the current dma instruction is an end of operation inst ruction, the instruction status register is reset to the instruction boundary register. if the continuous conversion bit (bit 7, ccnv) in the end of operation instruction word is set to ?1?, the dma will continue to execute instructio ns. when ccnv is set to ?0?, the dma will stop executing instructions at this point. an example of mode 1 operation is shown in figure 6.3. 00000000 0x3f 00110000 00010000 01000000 0x01 0x02 0x03 ... 0x00 dma0bnd adc0h adc0l instruction buffer (64 bytes) xram adc0h (diff.) adc0l (diff.) adc0h adc0l adc1h adc1l adc0h adc0l adc0h adc0l dma0csh:l = dma0cth:l dma0csh:l = dma0cth:l - 1 dma0csh:l = 0x0000 dma0csh:l = dma0cth:l adc0h (diff.) adc0l (diff.) dma0csh:l = 0x0000 dma0csh:l = dma0cth:l adc0h adc0l adc1h adc1l dma0csh:l = 0x0000 figure 6.3. dma mode 1 operation
c8051f060/1/2/3/4/5/6/7 rev. 1.2 79 6.6. interrupt sources the dma contains multiple interrupt sources. some of these can be individually enabled to generate inter- rupts as necessary. the dma control register (dma0cn, figure 6.4) and dma configuration register (dma0cf, figure 6.5) contain the enable bits and flag s for the dma interrupt sources. when an interrupt is enabled and the in terrupt condition occurs, a dma interrupt will be generated (eie2.7 is set to ?1?). the dma flags that can generate a dma0 interrupt are: 1. dma operations complete (dma0cn.6, dma0int) occurs when all dma operations have been completed, and the dma interface is idle. 2. adc1 data overflow error (dma0cn.4, dma0 de1) occurs when the dma interface cannot access xram for two conversion cycles of adc1. this flag indicates that at least one conver- sion result from adc1 has been discarded. 3. adc0 data overflow error (dma0cn.3, dma0 de0) occurs when the dma interface cannot access xram for two conversion cycles of adc0. this flag indicates that at least one conver- sion result from adc0 has been discarded. 4. adc1 data overflow warning (dma0cn.1, dma0do1) occurs when data from adc0 becomes available and the dma has not yet written the previous results to xram. this inter- rupt source can be enabled and disabled wi th the data overflow warning enable bit (dma0cn.2, dma0doe). 5. adc0 data overflow warning (dma0cn.0, dma0do0) occurs when data from adc1 becomes available and the dma has not yet written the previous results to xram. this inter- rupt source can be enabled and disabled wi th the data overflow warning enable bit (dma0cn.2, dma0doe). 6. repeat counter overflow (dma0cf.2, dma0 ci) occurs when the repeat counter reaches the repeat counter limit. this interrupt sour ce can be enabled and disabled with the repeat counter overflow interrupt enab le bit (dma0cf.3, dma0cie). 7. end of operation (dma0cf.0, dma0eo) occurs when an end of operation instruction is reached in the instruction buffer. this interrupt source can be enabled and disabled with the end of operation interrupt enable bit (dma0cf.1, dma0eoe). 6.7. data buffer overflow warnings and errors the data paths from the adcs to xram are double-bu ffered when using the dma interface. when a con- version is completed by the adc, it first enters the a dcs data register. if the dma?s data buffer is empty, the conversion results will immediately be written into the dma? s internal data buffer for that adc. data in the dma?s internal data buffer is written to xram at the first available opportunity (see section ?6.3. xram addressing and setup? on page 76 ). conversion results from the adc?s data registers are not copied into the dma?s data buffer until data in the buffer has be en written to xram. when a conversion is completed and the dma?s data buffer is not empty, an overflow warning flag is generated. if a second conversion data word becomes available before the dma?s data buffer is written to xram, the data in the adc?s data regis- ters is over-written with the new data word, a nd a data overflow error flag is generated.
c8051f060/1/2/3/4/5/6/7 80 rev. 1.2 figure 6.4. dma0cn: dma0 control register bit 7: dma0en: dma0 enable. write: 0: stop dma0 operations. 1: begin dma0 operations. read: 0: dma0 is idle. 1: dma0 operation is in progress. bit 6: dma0int: dma0 operations complete flag. 0: dma0 has not comp leted all operations. 1: dma0 operations are complete. this bit must be cleared by software. bit 5: dma0md: dma0 mode select. 0: dma0 will operate in mode 0. 1: dma0 will operate in mode 1. bit 4: dma0de1: adc1 data overflow error flag. 0: adc1 data overflow has not occured. 1: adc1 data overflow has occured, and data from adc1 has been lost. this bit must be cleared by software. bit 3: dma0de0: adc0 data overflow error flag. 0: adc0 data overflow has not occured. 1: adc0 data overflow has occured, and data from adc0 has been lost. this bit must be cleared by software. bit 2: dma0doe: data overflow warning interrupt enable. 0: disable data overfl ow warning interrupts. 1: enable data overfl ow warning interrups. bit 1: dma0do1: adc1 data overflow warning flag. 0: no adc1 data buffer warnings have been issued. 1: adc1 data buffer is full, and the dma has not written previous data to xram. this bit must be cleared by software. bit 0: dma0do0: adc0 data overflow warning flag. 0: no adc0 data buffer warnings have been issued. 1: adc0 data buffer is full, and the dma has not written previous data to xram. this bit must be cleared by software. sfr page: sfr address: 3 0xd8 (bit addressable) r/w r/w r/w r/w r/w r/w r/w r/w reset value dma0en dma0int dma0md dma0de1 dma0de0 dma0doe dma0do1 dma0do0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 81 figure 6.5. dma0cf: dma0 configuration register bit 7: dma0hlt: halt dma0 off-chip xram access (c8051f060/2/4/6 only). 0: dma0 has complete a ccess to off-chip xram. 1: processor core has complete access to off- chip xram. dma0 will wait until this bit is ?0? before writing to off- chip xram locations. bit 6: dma0xby: off-chip xram bu sy flag (c8051f060/2/4/6 only). 0: dma0 is not accessing off-chip xram. 1: dma0 is accessing off-chip xram. bits 5-4: reserved. write to 00b. bit 3: dma0cie: repeat counter overflow interrupt enable. 0: disable repeat counter overflow interrupt. 1: enable repeat counter overflow interrupt. bit 2: dma0ci: repeat counter overflow flag. 0: repeat counter overflow has not occured. 1: repeat counter overflow has occured. this bit must be cleared by software. bit 1: dma0eoe: end-of-o peration interrupt enable. 0: disable end-of-operation interrupt. 1: enable end-of-o peration interrupt. bit 0: dma0eo: end- of-operation flag. 0: end-of-operation instruction has not been received. 1: end-of-operation instruction has been received. this bit must be cleared by software. sfr page: sfr address: 3 0xf8 (bit addressable) r/w r r/w r/w r/w r/w r/w r/w reset value dma0hlt dma0xby - - dma0cie dma0ci dma0eoe dma0eo 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 82 rev. 1.2 figure 6.6. dma0ipt: dma0 instruction write address register bits 7-6: unused. bits 5-0: dma0 instruction address to write (or read) . when dma0idt is written or read, this register will be incremented to point to the next instruction address. sfr page: sfr address: 3 0xdd r r r/w r/w r/w r/w r/w r/w reset value -- 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.7. dma0idt: dma0 instruction write data register bit 7: ccnv: continuous conversion. 0: disable continuous conversion. 1: enable continuous co nversion. repeat counter value is ignored, and conversions will continue. bit 6: diffsel: wait for data in differential mode. 0: differential data will not be collected. 1: wait for differential data, and store to xram. bit 5: adc1en: wait for data from adc1. 0: adc1 data will not be collected. 1: wait for adc1 data, and store to xram. bit 4: adc0en: wait for data from adc0. 0: adc0 data will not be collected. 1: wait for adc0 data, and store to xram. if diffsel is also ?1?, only the differential data will be stored. bits 3-0: reserved. write to 0000b. for more details on dma instruction words, see section ?6.2. dma0 instruction format? on page 76 . ? this register points to a dedicated ram location and its reset value is indeterminate. sfr page: sfr address: 3 0xde r/w r/w r/w r/w r/w r/w r/w r/w reset value? ccnv diffsel adc1en adc0en - - - - xxxxxxxx bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 83 figure 6.8. dma0bnd: dma0 inst ruction bounda ry register bits 7-6: unused. bits 5-0: dma0 instruction address to beg in with when executing dma instructions. sfr page: sfr address: 3 0xfd r/w r/w r/w r/w r/w r/w r/w r/w reset value -- 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.9. dma0isw: dma0 in struction status register bits 7-6: unused. bits 5-0: contains the address of the cu rrent dma0 instruction to be executed. sfr page: sfr address: 3 0xfe r/w r/w r/w r/w r/w r/w r/w r/w reset value -- 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 84 rev. 1.2 figure 6.10. dma0dah: dma0 data address beginning msb register bits 7-0: dma0 address beginning high-order bits. sfr page: sfr address: 3 0xda r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.11. dma0dal: dma0 data address beginning lsb register bits 7-0: dma0 address beginning low-order bits. sfr page: sfr address: 3 0xd9 r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.12. dma0dsh: dma0 data address pointer msb register bits 7-0: dma0 address pointer high-order bits. sfr page: sfr address: 3 0xdc r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.13. dma0dsl: dma0 data address pointer lsb register bits 7-0: dma0 address pointer low-order bits. sfr page: sfr address: 3 0xdb r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 85 figure 6.14. dma0cth: dma0 repe at counter limit msb register bits 7-0: dma0 repeat counter limit high-order bits. sfr page: sfr address: 3 0xfa r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.15. dma0ctl: dma0 repeat counter limit lsb register bits 7-0: dma0 repeat counter limit low-order bits. sfr page: sfr address: 3 0xf9 r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.16. dma0csh: dma0 repeat counter msb register bits 7-0: dma0 repeat counter high-order bits. sfr page: sfr address: 3 0xfc r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 6.17. dma0csl: dma0 repeat counter lsb register bits 7-0: dma0 repeat counter low-order bits. sfr page: sfr address: 3 0xfb r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 86 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 87 7. 10-bit adc (adc2, c8051f060/1/2/3) the adc2 subsystem for the c8051f060/1/2/3 consists of an analog multiplexer (referred to as amux2), and a 200 ksps, 10-bit successive-approximation-regi ster adc with integrated track-and-hold and pro- grammable window detector (see block diagram in figure 7.1). the amux2, data conversion modes, and window detector can all be configured from within so ftware via the special function registers shown in figure 7.1. adc2 operates in both single-ended and differential modes, and may be configured to mea- sure any of the pins on port 1, or the temperatur e sensor output. the adc2 subsystem is enabled only when the ad2en bit in the adc2 co ntrol register (adc2cn) is set to logic 1. the adc2 subsystem is in low power shutdown when this bit is logic 0. 10-bit sar adc ref temp sensor 10 9-to-1 amux (se or diff) av+ 20 10 ad2en sysclk ain2.0 ain2.1 ain2.2 ain2.3 ain2.4 ain2.5 ain2.6 ain2.7 start conversion agnd adc2l adc2h adc2ltl adc2lth adc2gtl adc2gth ad2cm timer 3 overflow timer 2 overflow 00 01 10 11 ad2busy (w) cnvstr2 ad2wint comb. logic amx2sl amx2ad0 amx2ad1 amx2ad2 amx2ad3 amx2cf ain01ic ain23ic ain45ic ain67ic adc2cf ad2sc0 ad2sc1 ad2sc2 ad2sc3 ad2sc4 adc2cn ad2ljst ad2wint ad2cm0 ad2cm1 ad2busy ad2int ad2tm ad2en ad2cm figure 7.1. adc2 functional block diagram
c8051f060/1/2/3/4/5/6/7 88 rev. 1.2 7.1. analog multiplexer the analog multiplexer (amux2) selects the inputs to the adc, allowing any of the pins on port 1 to be measured in single-ended mode, or as a differential pair. additionally, the on-chip temperature sensor may be selected as a single-ended input. the adc2 input channels are configured and selected in the amx2cf and amx2sl registers as described in figu re 7.5 and figure 7.6, respectively. in single-ended mode, the selected pin is measured with respect to agnd. in differential mode, the selected differential pair is measured with respect to one another. the polarity of the differential measurement depends on the setting of the amx2ad3-0 bits in the amx2sl register. for example, if pins ain2.0 and ain2.1 are config- ured for differential measuremen t (ain01ic = 1), and amx2ad3-0 = 0000b, the adc will measure the volt- age (ain2.0 - ain2.1). if amx2ad3- 0 is changed to 0001b, the adc will measure the same voltage, with opposite polarity (ain2.1 - ain2.0). the conversion code format differs between single -ended and differential modes. the registers adc2h and adc2l contain the high and low bytes of the outpu t conversion code from the adc at the completion of each conversion. data can be right-justified or left -justified, depending on the setting of the ad2ljst bit (adc2cn.0). when in single-ended mode, conversion codes are represented as 10-bit unsigned integers. inputs are measured from ?0? to vref * 1023/1024. example codes are shown below for both right-justified and left-justified data. unused bits in the adc2h and adc2l registers are set to ?0?. when in differential mode, conversion codes are represented as 10-bit signed 2?s complement numbers. inputs are measured from -vref to vref * 511/512. example codes are shown bel ow for both right-justi- fied and left-justified data. for ri ght-justified data, the unused msbs of adc2h are a sign-extension of the data word. for left-justified data, the unused lsbs in the adc2l register are set to ?0?. important note about adc2 input configuration: port 1 pins selected as adc2 inputs should be con- figured as analog inputs. to configure a port 1 pin for analog input, set to ?1? the corresponding bit in regis- ter p1mdin. port 1 pins used as adc2 inputs will be skipped by the crossbar for peripheral assignments. see section ?18. port input/output? on page 203 for more port i/o configuration details. the temperature sensor transfer function is show n in figure 7.2 on page 89. the output voltage (v temp ) is a single-ended input to adc2 when the temperatur e sensor is selected by bi ts amx2ad3-0 in register amx2sl. typical values for the slope and offset parameters can be found in table 7.1. input voltage right-justified adc2h:adc2l (ad2ljst = 0) left-justified adc2h:adc2l (ad2ljst = 1) vref * 1023/1024 0x03ff 0xffc0 vref * 512/1024 0x0200 0x8000 vref * 256/1024 0x0100 0x4000 0 0x0000 0x0000 input voltage right-jus tified adc2h:adc2l (ad2ljst = 0) left-justified adc2h:adc2l (ad2ljst = 1) vref * 511/512 0x01ff 0x7fc0 vref * 256/512 0x0100 0x4000 0 0x0000 0x0000 -vref * 256/512 0xff00 0xc000 - vref 0xfe00 0x8000
c8051f060/1/2/3/4/5/6/7 rev. 1.2 89 7.2. modes of operation adc2 has a maximum conversion speed of 200 ksps. the adc2 conversion clock is a divided version of the system clock, determined by the ad2sc bits in the adc2cf register (syste m clock divided by (ad2sc + 1) for 0 ad2sc 31). the adc2 conversion clock should be no more than 3 mhz. 7.2.1. starting a conversion a conversion can be initiated in one of four ways, depending on the programmed states of the adc2 start of conversion mode bits (ad2cm1-0) in register a dc2cn. conversions may be initiated by one of the fol- lowing: 1. writing a ?1? to the ad2busy bit of register adc2cn 2. a timer 3 overflow (i.e. timed continuous conversions) 3. a rising edge on the cnvstr2 input signal (assigned by the crossbar) 4. a timer 2 overflow when cnvstr2 is used as a conversion start source, it must be enabled in the crossbar, and the corre- sponding pin must be set to open-drain, high-impedance mode (see section ?18. port input/output? on page 203 for more details on port i/o configuration). writing a ?1? to ad2busy provides software contro l of adc2 whereby conversions are performed "on- demand". during conversion, the ad2busy bit is set to logic 1 and reset to logic 0 when the conversion is complete. the falling edge of ad2bu sy triggers an interrupt (when enabl ed) and sets the adc2 interrupt flag (ad2int). note: when polling for adc conversi on completions, the adc2 interrupt flag (ad2int) should be used. converted data is available in the adc2 data registers, adc2h and adc2l, when bit ad2int is logic 1. note that when timer 2 or time r 3 overflows are used as the conversion source, low byte overflows are used if the timer is in 8-bit mode; and high byte overflows are used if the timer is in 16- bit mode. see section ?24. timers? on page 287 for timer configuration. 0 -50 50 100 temperature (celsius) voltage v temp = ( slope x temp c ) + offset offset (v at 0 celsius) slope (v / deg c) temp c = (v temp - offset ) / slope figure 7.2. temperature sensor transfer function
c8051f060/1/2/3/4/5/6/7 90 rev. 1.2 7.2.2. tracking modes the ad2tm bit in register adc2cn controls the adc2 track-and-hold mode. in its default state, the adc2 input is continuously tracked, except when a conversi on is in progress. when the ad2tm bit is logic 1, adc2 operates in low-power track-and-hold mode. in this mode, each conversion is preceded by a track- ing period of 3 sar clocks (after the start-of-conversio n signal). when the cnvstr2 signal is used to ini- tiate conversions in low-power tracking mode, adc2 tracks only when cnvstr2 is low; conversion begins on the rising edge of cnvstr2 (see figure 7.3). tracking can also be disabled (shutdown) when the device is in low power standby or sleep modes. low-power track-and-hold mode is also useful when amux settings are frequently changed, due to the settling time requirements described in section ?7.2.3. settling time requirements? on page 91 . figure 7.3. 10-bit adc track a nd conversion example timing write '1' to ad2busy, timer 3, timer 2 overflow (ad2cm[1:0]=00, 01, 11) ad2tm=1 track convert low power mode ad2tm=0 track or convert convert track low power or convert sar clocks 123456789101112 123456789 sar clocks b. adc2 timing for internal trigger source 123456789 cnvstr2 (ad2cm[1:0]=10) ad2tm=1 a. adc2 timing for external trigger source sar clocks track or convert convert track ad2tm=0 track convert low power mode low power or convert 10 11 13 14 10 11
c8051f060/1/2/3/4/5/6/7 rev. 1.2 91 7.2.3. settling time requirements a minimum tracking time is required before an accurate conversion can be performe d. this tracking time is determined by the amux2 resistance, the adc2 samp ling capacitance, any exte rnal source resistance, and the accuracy required for the conversion. note t hat in low-power tracking mode, three sar clocks are used for tracking at the start of every conversion. for mo st applications, these three sar clocks will meet the minimum tracking time requirements. figure 7.4 shows the equivalent adc2 input circuits for both differential and single-ended modes. notice that the equivalent time constant for both input circ uits is the same. the required adc2 settling time for a given settling accuracy (sa) may be approximated by equation 7.1. when measuring the temperature sensor output, r total reduces to r mux . see table 7.1 for adc2 mini mum settling time requirements. where: sa is the settling accuracy, given as a fraction of an lsb (for example, 0.25 to settle within 1/4 lsb) t is the required settling time in seconds r total is the sum of the amux2 resistance and any external source resistance. n is the adc resolution in bits (10). equation 7.1. adc2 settling time requirements t 2 n sa ------ - ?? ?? r total c sample ln = r mux = 5k rc input = r mux * c sample r mux = 5k c sample = 5pf c sample = 5pf mux select mux select differential mode p1.x p1.y r mux = 5k c sample = 5pf rc input = r mux * c sample mux select single-ended mode p1.x figure 7.4. adc2 equivalent input circuits
c8051f060/1/2/3/4/5/6/7 92 rev. 1.2 figure 7.5. amx2cf: amux2 configuration register bits 7-4: unused. read = 0000b; write = don?t care. bit 3: ain67ic: ain2.6, ain2.7 input pair configuration bit. 0: ain2.6 and ain2.7 are independent, single-ended inputs. 1: ain2.6 and ain2.7 are a differential input pair. bit 2: ain45ic: ain2.4, ain2.5 input pair configuration bit. 0: ain2.4 and ain2.5 are independent, single-ended inputs. 1: ain2.4 and ain2.5 are a differential input pair. bit 1: ain23ic: ain2.2, ain2.3 input pair configuration bit. 0: ain2.2 and ain2.3 are independent, single-ended inputs. 1: ain2.2 and ain2.3 are a differential input pair. bit 0: ain01ic: ain2.0, ain2.1 input pair configuration bit. 0: ain2.0 and ain2.1 are independent, single-ended inputs. 1: ain2.0 and ain2.1 are a differential input pair. note: the adc2 data word is in the 2?s complement format for channels configured as differen- tial. the polarity of a differential measurement is determined by the amx2sl setting. see figure 7.5 for more details on multiplexer chan nel selection. sfr page: sfr address: 2 0xba r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - ain67ic ain45ic ain23ic ain01ic 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 93 figure 7.6. amx2sl: amux2 channel select register bits 7-4: unused. read = 0000b; write = don?t care. bits 3-0: amx2ad3-0: amx2 address bits. 0000-1111b: adc input multiplexer channel selected per chart below. sfr page: sfr address: 2 0xbb r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - amx2ad3 amx2ad2 amx2ad1 amx2ad0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 amx2ad3-0 single-ended measurement amx2ad3-0 differential measurement 0000 ain2.0 ain01ic = 0 0000 +(ain2.0) -(ain2.1) ain01ic = 1 0001 ain2.1 0001 +(ain2.1) -(ain2.0) 0010 ain2.2 ain23ic = 0 0010 +(ain2.2) -(ain2.3) ain23ic = 1 0011 ain2.3 0011 +(ain2.3) -(ain2.2) 0100 ain2.4 ain45ic = 0 0100 +(ain2.4) -(ain2.5) ain45ic = 1 0101 ain2.5 0101 +(ain2.5) -(ain2.4) 0110 ain2.6 ain67ic = 0 0110 +(ain2.6) -(ain2.7) ain67ic = 1 0111 ain2.7 0111 +(ain2.7) -(ain2.6) 1xxx temperature sensor 1xxx -
c8051f060/1/2/3/4/5/6/7 94 rev. 1.2 figure 7.7. adc2cf: adc2 configuration register bits7-3: ad2sc4-0: adc2 sar co nversion clock period bits. sar conversion clock is deri ved from system clock by the following equation, where adsc refers to the 5-bit value held in bits ad2sc4-ad2sc0. sar conversion clock requirements are given in table 7.1. bits2-0: unused. read = 000b; write = don?t care. sfr page: sfr address: 2 0xbc r/w r/w r/w r/w r/w r/w r/w r/w reset value ad2sc4 ad2sc3 ad2sc2 ad2sc1 ad2sc0 - - - 11111000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 adsc sysclk clk sar --------------------- -1 ? =
c8051f060/1/2/3/4/5/6/7 rev. 1.2 95 figure 7.8. adc2h: adc2 data word msb register bits7-0: adc2 data word high-order bits. for ad2ljst = 0: bits 7-2 are t he sign extension of bit 1. bits 1-0 are the upper 2 bits of the 10-bit adc2 data word. for ad2ljst = 1: bits 7-0 are the most-significant bits of the 10-bit adc2 data word. sfr page: sfr address: 2 0xbf r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 7.9. adc2l: adc2 data word lsb register bits7-0: adc2 data word low-order bits. for ad2ljst = 0: bits 7-0 are the lower 8 bits of the 10-bit data word. for ad2ljst = 1: bits 7-6 are th e lower 2 bits of the 10-bit data word. bits 5-0 will always read ?0?. sfr page: sfr address: 2 0xbe r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 96 rev. 1.2 figure 7.10. adc2cn: adc2 control register bit 7: ad2en: adc2 enable bit. 0: adc2 disabled. adc2 is in low-power shutdown. 1: adc2 enabled. adc2 is active and ready for data conversions. bit6: ad2tm: adc2 track mode bit. 0: normal track mode: when adc2 is enabled , tracking is continuous unless a conversion is in progress. 1: low-power track mode: tracking defined by ad2cm2-0 bits (see below). bit5: ad2int: adc2 conversion complete interrupt flag. 0: adc2 has not completed a data conversi on since the last time ad2int was cleared. 1: adc2 has completed a data conversion. bit 4: ad2busy: adc2 busy bit. read: 0: adc2 conversion is complete or a conversion is not currently in progress. ad2int is set to logic 1 on the falling edge of ad2busy. 1: adc2 conversion is in progress. write: 0: no effect. 1: initiates adc2 conversion if ad2cm2-0 = 000b bits 3-2: ad2cm1-0: adc2 start of conversion mode select. when ad2tm = 0: 00: adc2 conversion initiated on every write of ?1? to ad2busy. 01: adc2 conversion initiated on overflow of timer 3. 10: adc2 conversion initiated on rising edge of external cnvstr2 pin. 11: adc2 conversion initiated on overflow of timer 2. when ad2tm = 1: 00: tracking initiated on write of ?1? to ad 2busy and lasts 3 sar clocks, followed by con- version. 01: tracking initiated on overflow of timer 3 and lasts 3 sar clocks, followed by conver- sion. 10: adc2 tracks only when cnvstr2 input is logic low; conversion starts on rising cnvstr2 edge. 11: tracking initiated on overflow of timer 2 and lasts 3 sar clocks, followed by conversion. bit 1: ad2wint: adc2 windo w compare interrupt flag. 0: adc2 window comparison data match has not occurred since this flag was last cleared. 1: adc2 window comparison data match has occurred. bit 0: ad2ljst: adc2 left justify select. 0: data in adc2h:adc2l r egisters are right-justified. 1: data in adc2h:adc2l r egisters are left-justified. sfr page: sfr address: 2 0xe8 (bit addressable) r/w r/w r/w r/w r/w r/w r/w r/w reset value ad2en ad2tm ad2int ad2busy ad2cm1 ad2cm0 ad2wint ad2ljst 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 97 7.3. programmable window detector the adc programmable window detector continuously compares the adc2 output registers to user-pro- grammed limits, and notifies the system when a desired condition is detected. this is especially effective in an interrupt-driven system, saving code space and cpu bandwidth while delivering faster system response times. the window detector interrupt flag (ad2wint in register adc2cn) can also be used in polled mode. the adc2 greater-t han (adc2gth, adc2gtl) and less-than (adc2lth, adc2ltl) reg- isters hold the comparison values. the window detector flag can be programmed to indicate when mea- sured data is inside or outside of the user-progr ammed limits, depending on the contents of the adc2 less-than and adc2 greater-than registers. figure 7.11. adc2gth: adc2 greater-than data high byte register bits7-0: high byte of adc2 greater-than data word. sfr page: sfr address: 2 0xc5 r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 7.12. adc2gtl: adc2 greate r-than data low byte register bits7-0: low byte of adc2 greater-than data word. sfr page: sfr address: 2 0xc4 r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 98 rev. 1.2 figure 7.13. adc2lth: a dc2 less-than data high byte register bits7-0: high byte of adc2 less-than data word. sfr page: sfr address: 2 0xc7 r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 figure 7.14. adc2ltl: adc2 less- than data low byte register bits7-0: low byte of adc2 less-than data word. sfr page: sfr address: 2 0xc6 r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 99 7.3.1. window detector in single-ended mode figure 7.15 shows two example window comparisons for right-justified, single-ended data, with adc2lth:adc2ltl = 0x0080 (128d) and adc2gth:adc2gtl = 0x0040 (64d). in single-ended mode, the input voltage can range from ?0? to vref * (1023/1 024) with respect to agnd, and is represented by a 10-bit unsigned integer va lue. in the left example, an ad2wint interrupt will be generated if the adc2 conversion word (adc2h:adc2l) is within the range defined by adc2gth:adc2gtl and adc2lth:adc2ltl (if 0x0040 < adc2h:adc2l < 0x0080). in the right example, and ad2wint interrupt will be generated if the adc2 conversion word is outside of t he range defined by the adc2gt and adc2lt registers (if adc2h:adc2l < 0x0040 or a dc2h:adc2l > 0x0080). figure 7.16 shows an exam- ple using left-justified data with the same comparison values. 0x03ff 0x0081 0x0080 0x007f 0x0041 0x0040 0x003f 0x0000 0 input voltage (p1.x - agnd) vref x (1023/1024) vref x (128/1024) vref x (64/1024) ad2wint=1 ad2wint not affected ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl 0x03ff 0x0081 0x0080 0x007f 0x0041 0x0040 0x003f 0x0000 0 input voltage (p1.x - agnd) vref x (1023/1024) vref x (128/1024) vref x (64/1024) ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint=1 ad2wint=1 adc2h:adc2l adc2h:adc2l figure 7.15. adc window compare example: right-justified single-ended data 0xffc0 0x2040 0x2000 0x1fc0 0x1040 0x1000 0x0fc0 0x0000 0 input voltage (p1.x - agnd) vref x (1023/1024) vref x (128/1024) vref x (64/1024) ad2wint=1 ad2wint not affected ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl 0xffc0 0x2040 0x2000 0x1fc0 0x1040 0x1000 0x0fc0 0x0000 0 input voltage (p1.x - agnd) vref x (1023/1024) vref x (128/1024) vref x (64/1024) ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint=1 ad2wint=1 adc2h:adc2l adc2h:adc2l figure 7.16. adc window compare example: left-justified single-ended data
c8051f060/1/2/3/4/5/6/7 100 rev. 1.2 7.3.2. window detector in differential mode figure 7.17 shows two example wi ndow comparisons for right-justif ied, differential data, with adc2lth:adc2ltl = 0x0040 (+64d) and adc2gth:adc2gth = 0xffff (-1d). in differential mode, the measurable voltage between the input pins is between -vref and vref*(511/512). output codes are rep- resented as 10-bit 2?s complement signed integers. in the left example, an ad 2wint interrupt will be gen- erated if the adc2 conversion word (adc2h:adc2l) is within the range defined by adc2gth:adc2gtl and adc2lth:adc2ltl (if 0xffff (-1d) < adc2h:adc2 l < 0x0040 (64d)). in the right example, an ad2wint interrupt will be generated if the adc2 conversion word is ou tside of the range defined by the adc2gt and adc2lt registers (if adc2h:adc2 l < 0xffff (-1d) or adc2h:adc2l > 0x0040 (+64d)). figure 7.18 shows an example using left-justifi ed data with the same comparison values. 0x01ff 0x0041 0x0040 0x003f 0x0000 0xffff 0xfffe 0x0200 -vref input voltage (p1.x - p1.y) vref x (511/512) vref x (64/512) vref x (-1/512) 0x01ff 0x0041 0x0040 0x003f 0x0000 0xffff 0xfffe 0x0200 -vref input voltage (p1.x - p1.y) vref x (511/512) vref x (64/512) vref x (-1/512) ad2wint=1 ad2wint not affected ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint=1 ad2wint=1 adc2h:adc2l adc2h:adc2l figure 7.17. adc window compare example: right-justified differential data 0x7fc0 0x1040 0x1000 0x0fc0 0x0000 0xffc0 0xff80 0x8000 -vref input voltage (p1.x - p1.y) vref x (511/512) vref x (64/512) vref x (-1/512) 0x7fc0 0x1040 0x1000 0x0fc0 0x0000 0xffc0 0xff80 0x8000 -vref input voltage (p1.x - p1.y) vref x (511/512) vref x (64/512) vref x (-1/512) ad2wint=1 ad2wint not affected ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint not affected adc2lth:adc2ltl adc2gth:adc2gtl ad2wint=1 ad2wint=1 adc2h:adc2l adc2h:adc2l figure 7.18. adc window compare example: left-justified differential data
c8051f060/1/2/3/4/5/6/7 rev. 1.2 101 table 7.1. adc2 electrical characteristics vdd = 3.0 v, vref = 2.40 v (refsl =0), pga gain = 1, -40c to +85c unless otherwise specified parameter conditions min typ max units dc accuracy resolution 10 bits integral nonlinearity 0.5 1 lsb differential nonlinearity guar anteed monotonic 0.5 1 lsb offset error -12 1 12 lsb full scale error differential mode -15 -5 5 lsb offset temperature coefficient 3.6 ppm/c dynamic performance (10 khz sine -wave differential input, 1 db below full scale, 200 ksps) signal-to-noise plus distortion 53 55.5 db total harmonic distortion up to the 5 th harmonic -67 db spurious-free dynamic range 78 db conversion rate sar conversion clock 3 mhz conversion time in sar clocks 10 clocks track/hold acquisition time 300 ns throughput rate 200 ksps analog inputs adc input voltage range single ended (ain+ - agnd) differential (ain+ - ain-) 0 -vref vref vref v v absolute pin voltage with respect to agnd single ended or differential 0 av+ v input capacitance 5 pf temperature sensor linearity 0.2 c offset temp = 0 c 776 mv offset error (note 1) temp = 0 c 8.9 mv slope 2.89 mv/c slope error (note 1) 63 v/c power specifications power supply current (vdd sup- plied to adc2) operating mode, 200 ksps 400 900 a power supply rejection 0.3 mv/v note 1: represents one standard deviation from the mean value.
c8051f060/1/2/3/4/5/6/7 102 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 103 8. dacs, 12-bit voltage mode (d ac0 and dac1, c8051f060/1/2/3) the c8051f060/1/2/3 devices include two on-chip 12-bit voltage-mode digital-to-analog converters (dacs). each dac has an output swing of 0 v to (vref-1lsb) for a corresponding input code range of 0x000 to 0xfff. the dacs may be enabled/disabled via their corresponding control registers, dac0cn and dac1cn. while disabled, the dac output is maintained in a high-impedance state, and the dac sup- ply current falls to 1 a or less. the voltage refe rence for each dac is supplied at the vrefd pin (c8051f060/2 devices) or the vref2 pin (c8051f061/3 devices). see section ?9. voltage reference 2 (c8051f060/2)? on page 111 or section ?10. voltage reference 2 (c8051f061/3)? on page 113 for more information on conf iguring the voltage reference for the dacs. note that th e biase bit described in the voltage reference sections must be set to ?1? to use the dacs. dac0 av+ 12 agnd 8 8 ref dac0 dac0cn dac0en dac0md1 dac0md0 dac0df2 dac0df1 dac0df0 dac0h dac0l dig. mux latch latch 8 8 dac1 av+ 12 agnd 8 8 ref dac1 dac1cn dac1en dac1md1 dac1md0 dac1df2 dac1df1 dac1df0 dac1h dac1l dig. mux latch latch 8 8 dac0h timer 3 timer 4 timer 2 dac1h timer 3 timer 4 timer 2 figure 8.1. dac functional block diagram
c8051f060/1/2/3/4/5/6/7 104 rev. 1.2 8.1. dac output scheduling each dac features a flexible output update mechan ism which allows for seam less full-scale changes and supports jitter-free update s for waveform generation. the following ex amples are written in terms of dac0, but dac1 operation is identical. 8.1.1. update output on-demand in its default mode (dac0cn.[4:3] = ?00?) the dac0 output is updated ?on-demand? on a write to the high- byte of the dac0 data register (dac0h). it is import ant to note that writes to dac0l are held, and have no effect on the dac0 output until a wr ite to dac0h takes place. if writi ng a full 12-bit word to the dac data registers, the 12-bit data word is written to the low byte (dac0l) and high by te (dac0h) data registers. data is latched into dac0 after a writ e to the corresponding dac0h register, so the write sequence should be dac0l followed by dac0h if the full 12-bit resolution is required. the dac can be used in 8- bit mode by initializing dac0l to th e desired value (typically 0x00), a nd writing data to only dac0h (also see section 8.2 for information on formatting the 12-bit dac data word within the 16-bit sfr space). 8.1.2. update output based on timer overflow similar to the adc operation, in which an adc conv ersion can be initiated by a timer overflow indepen- dently of the processor, the dac outputs can use a timer overflow to schedule an output update event. this feature is useful in systems where the dac is used to generate a waveform of a defined sampling rate by eliminating the effects of variable interrupt latenc y and instruction execution on the timing of the dac output. when the dac0md bits (dac0cn.[4:3]) are set to ?01?, ?10?, or ?11?, writes to both dac data regis- ters (dac0l and dac0h) are held until an associated timer overflow event (timer 3, timer 4, or timer 2, respectively) occurs, at which time the dac0h:dac0l contents are copied to the dac input latches allow- ing the dac output to change to the new value. 8.2. dac output scaling/justification in some instances, input data should be shifted prio r to a dac0 write operatio n to properly justify data within the dac input registers. this action would typi cally require one or more load and shift operations, adding software overhead and slowing dac throughput. to alleviate this problem, the data-formatting fea- ture provides a means for the user to program the orie ntation of the dac0 data word within data registers dac0h and dac0l. the three dac0df bits (dac0cn.[2:0]) allow the user to specify one of five data word orientations as shown in the dac0cn register definition. dac1 is functionally the same as dac0 described above. the electrical specifications for both dac0 and dac1 are given in table 8.1.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 105 figure 8.2. dac0h: dac0 high byte register bits7-0: dac0 data word most significant byte. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd3 0 figure 8.3. dac0l: dac0 low byte register bits7-0: dac0 data word least significant byte. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd2 0
c8051f060/1/2/3/4/5/6/7 106 rev. 1.2 figure 8.4. dac0cn: dac0 control register bit7: dac0en: dac0 enable bit. 0: dac0 disabled. dac0 output pin is disa bled; dac0 is in low- power shutdown mode. 1: dac0 enabled. dac0 output pin is active; dac0 is operational. bits6-5: unused. read = 00b; write = don?t care. bits4-3: dac0md1-0: dac0 mode bits. 00: dac output updates o ccur on a write to dac0h. 01: dac output updates occur on timer 3 overflow. 10: dac output updates occur on timer 4 overflow. 11: dac output updates occur on timer 2 overflow. bits2-0: dac0df2-0: dac0 data format bits: 000: the most significant nibble of the dac0 data word is in dac0 h[3:0], while the least significant byte is in dac0l. 001: the most significant 5-bits of the dac0 data word is in dac0 h[4:0], while the least significant 7-bits are in dac0l[7:1]. 010: the most significant 6-bits of the dac0 data word is in dac0 h[5:0], while the least significant 6-bits are in dac0l[7:2]. 011: the most significant 7-bits of the dac0 data word is in dac0 h[6:0], while the least significant 5-bits are in dac0l[7:3]. 1xx: the most significant 8-bits of the dac0 data word is in dac0 h[7:0], while the least significant 4-bits are in dac0l[7:4]. r/w r/w r/w r/w r/w r/w r/w r/w reset value dac0en - - dac0md1 dac0md0 dac0df2 dac0df1 dac0df0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd4 0 dac0h dac0l msb lsb dac0h dac0l msb lsb dac0h dac0l msb lsb dac0h dac0l msb lsb dac0h dac0l msb lsb
c8051f060/1/2/3/4/5/6/7 rev. 1.2 107 figure 8.5. dac1h: dac1 high byte register bits7-0: dac1 data word most significant byte. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd3 1 figure 8.6. dac1l: dac1 low byte register bits7-0: dac1 data word least significant byte. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd2 1
c8051f060/1/2/3/4/5/6/7 108 rev. 1.2 figure 8.7. dac1cn: dac1 control register bit7: dac1en: dac1 enable bit. 0: dac1 disabled. dac1 output pin is disa bled; dac1 is in low- power shutdown mode. 1: dac1 enabled. dac1 output pin is active; dac1 is operational. bits6-5: unused. read = 00b; write = don?t care. bits4-3: dac1md1-0: dac1 mode bits: 00: dac output updates o ccur on a write to dac1h. 01: dac output updates occur on timer 3 overflow. 10: dac output updates occur on timer 4 overflow. 11: dac output updates occur on timer 2 overflow. bits2-0: dac1df2: dac1 data format bits: 000: the most significant nibble of the dac1 data word is in dac1 h[3:0], while the least significant byte is in dac1l. 001: the most significant 5-bits of the dac1 data word is in dac1 h[4:0], while the least significant 7-bits are in dac1l[7:1]. 010: the most significant 6-bits of the dac1 data word is in dac1 h[5:0], while the least significant 6-bits are in dac1l[7:2]. 011: the most significant 7-bits of the dac1 data word is in dac1 h[6:0], while the least significant 5-bits are in dac1l[7:3]. 1xx: the most significant 8-bits of the dac1 data word is in dac1 h[7:0], while the least significant 4-bits are in dac1l[7:4]. r/w r/w r/w r/w r/w r/w r/w r/w reset value dac1en - - dac1md1 dac1md0 dac1df2 dac1df1 dac1df0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd4 1 dac1h dac1l msb lsb dac1h dac1l msb lsb dac1h dac1l msb lsb dac1h dac1l msb lsb dac1h dac1l msb lsb
c8051f060/1/2/3/4/5/6/7 rev. 1.2 109 . table 8.1. dac electrical characteristics vdd = 3.0 v, av+ = 3.0 v, vref = 2.40 v (refbe = 0) , no output load unless otherwise specified parameter conditions min typ max units static performance resolution 12 bits integral nonlinearity 1.5 lsb differential non linearity 1 lsb output noise no output filter 100 khz output filter 10 khz output filter 250 128 41 vrms offset error data word = 0x014 3 30 mv offset tempco 6 ppm/c full-scale error 20 60 mv full-scale error tempco 10 ppm/c vdd power supply rejection ratio -60 db output impedance in shutdown mode dacnen = 0 100 k ? output sink current 300 a output short-circuit current data word = 0xfff 15 ma dynamic performance voltage output slew rate load = 40pf 0.44 v/s output settling time to 1/2 lsb load = 40pf, output swing from code 0xfff to 0x014 10 s output voltage swing 0 vref- 1lsb v startup time 10 s analog outputs load regulation i l = 0.01ma to 0.3ma at code 0xfff 60 ppm power consumption (each dac) power supply current (av+ supplied to dac) data word = 0x7ff 300 500 a
c8051f060/1/2/3/4/5/6/7 110 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 111 9. voltage reference 2 (c8051f060/2) the voltage refere nce circuitry offers full flex ibility in operating the adc2 and dac modules. two voltage reference input pins allow adc2 and the two dacs to reference an external voltage reference or the on- chip voltage reference output. adc2 may also refere nce the analog power supply voltage, via the vref multiplexer shown in figure 9.1. the internal voltage reference circuit consists of a 1.2 v, temperature stable bandgap voltage reference generator and a gain-of-two output buffer amplifier. the internal reference may be routed via the vref pin to external system components or to the voltage re ference input pins shown in figure 9.1. the maximum load seen by the vref pin must be less than 200 a to agnd. bypass capacitors of 0.1 f and 4.7 f are recommended from the vref pin to agnd, as shown in figure 9.1. the reference control register 2, re f2cn (defined in figure 9.2) enables/disables the internal reference generator and selects the reference input for adc2. the biase bit in ref2cn enables th e on-board refer- ence generator while the refbe bit enables the gain-of-two buffer amplifier which drives the vref pin. when disabled, the supply current drawn by the bandgap and buffer amplifier falls to less than 1 a (typi- cal) and the output of the buffer amplifier enters a hi gh impedance state. if the internal bandgap is used as the reference voltage generator, biase and refbe must bo th be set to logic 1. if the internal reference is not used, refbe may be set to logic 0. note that the biase bi t must be set to logi c 1 if adc2 or either dac is used, regardless of the voltage reference used. if neither adc2 nor the dacs are being used, both of these bits can be set to logic 0 to conserve po wer. bit ad2vrs selects be tween vref2 and av+ for the adc2 voltage reference source. the electrical specifications for the voltage reference are given in ta b l e 9 . 1 . recommended bypass capacitors x2 vref dac0 dac1 ref vrefd av+ adc2 vref2 ref 1 0 4.7 f0.1 f ref2cn refbe biase tempe ad2vrs refbe biase bias to adc2, dacs 1.2v band-gap en external voltage reference circuit r vdd + figure 9.1. voltage reference functional block diagram
c8051f060/1/2/3/4/5/6/7 112 rev. 1.2 the temperature sensor connects to the highest order input of the adc2 input multiplexer (see section ?7. 10-bit adc (adc2, c8051f060/1/2/3)? on page 87 ). the tempe bit within ref2cn enables and dis- ables the temperature sensor. while disabled, the temp erature sensor defaults to a high impedance state, and any a/d measurements performed on the sensor while disabled result in meaningless data. table 9.1. voltage reference electrical characteristics vdd = 3.0 v, av+ = 3.0 v, -40 to +85 c unless otherwise specified parameter conditions min typ max units internal reference (refbe = 1) output voltage 25 c ambient 2.36 2.43 2.48 v vref power supply current 50 a vref short-circuit current 30 ma vref temperature coefficient 15 ppm/c load regulation load = 0 to 200 a to agnd 0.5 ppm/a vref turn-on time 1 4.7 f tantalum, 0.1 f ceramic bypass 2ms vref turn-on time 2 0.1 f ceramic bypass 20 s vref turn-on time 3 no bypass cap 10 s external reference (refbe = 0) input voltage range 1.00 (av+) - 0.3 v input current 0 1 a figure 9.2. ref2cn: refere nce control register 2 bits7-4: unused. read = 0000b; write = don?t care. bit3: ad2vrs: adc2 volt age reference select. 0: adc2 voltage reference from vref2 pin. 1: adc2 voltage reference from av+. bit2: tempe: temperature sensor enable bit. 0: internal temperature sensor off. 1: internal temperature sensor on. bit1: biase: adc/dac bias ge nerator enable bit. (must be ?1 ? if using adc2 or dacs). 0: internal bias generator off. 1: internal bias generator on. bit0: refbe: internal refe rence buffer enable bit. 0: internal reference buffer off. 1: internal reference buffer on. internal voltage reference is driven on the vref pin. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - ad2vrs tempe biase refbe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd1 2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 113 10. voltage referen ce 2 (c8051f061/3) the internal voltage reference circuit consists of a 1.2 v, temperature stable bandgap voltage reference generator and a gain-of-two output buffer amplifier. the internal reference may be routed via the vref pin to external system components or to the vref2 input pin shown in figure 10.1. the maximum load seen by the vref pin must be less than 200 a to agnd. bypass capacitors of 0.1 f and 4.7 f are recom- mended from the vref pin to agnd, as shown in figure 10.1. the vref2 pin provides a voltage reference input for adc2 and the dacs. adc2 may also reference the analog power supply voltage, via the vref multiplexers shown in figure 10.1. the reference control register 2, ref2cn (defined in figure 10.2) enables/disables the internal refer- ence generator and selects the reference input for adc2. the biase bit in ref2cn enables the on-board reference generator while the refbe bit enables the gain-of-two buffer amplifier which drives the vref pin. when disabled, the supply current drawn by th e bandgap and buffer amplifier falls to less than 1 a (typical) and the output of the buffer amplifier enters a high impedance state. if the internal bandgap is used as the reference voltage generator, biase and refbe must both be set to logic 1. if the internal ref- erence is not used, refbe may be set to logic 0. note that the biase bit must be set to logic 1 if adc2 or either dac is used, regardless of the voltage reference used. if neither adc2 nor the dacs are being used, both of these bits can be set to logic 0 to conserve power. bit ad2vrs selects between vref2 and av+ for the adc2 voltage reference source. the electr ical specifications for the voltage reference are given in table 10.1. recommended bypass capacitors x2 vref dac0 dac1 ref av+ adc2 ref 1 0 vref2 4.7 f0.1 f ref2cn refbe biase tempe ad2vrs refbe biase bias to adc2, dacs 1.2v band-gap en external voltage reference circuit r vdd + figure 10.1. voltage reference functional block diagram
c8051f060/1/2/3/4/5/6/7 114 rev. 1.2 the temperature sensor connects to the highest order input of the adc2 input multiplexer (see section ?7. 10-bit adc (adc2, c8051f060/1/2/3)? on page 87 ). the tempe bit within ref2cn enables and dis- ables the temperature sensor. while disabled, the temp erature sensor defaults to a high impedance state, and any a/d measurements performed on the sensor while disabled result in meaningless data. table 10.1. voltage reference electrical characteristics vdd = 3.0 v, av+ = 3.0 v, -40 to +85 c unless otherwise specified parameter conditions min typ max units internal reference (refbe = 1) output voltage 25 c ambient 2.36 2.43 2.48 v vref power supply current 50 a vref short-circuit current 30 ma vref temperature coefficient 15 ppm/c load regulation load = 0 to 200 a to agnd 0.5 ppm/a vref turn-on time 1 4.7 f tantalum, 0.1 f ceramic bypass 2ms vref turn-on time 2 0.1 f ceramic bypass 20 s vref turn-on time 3 no bypass cap 10 s external reference (refbe = 0) input voltage range 1.00 (av+) - 0.3 v input current 0 1 a figure 10.2. ref2cn: reference control register 2 bits7-4: unused. read = 0000b; write = don?t care. bit3: ad2vrs: adc2 volt age reference select. 0: adc2 voltage reference from vref2 pin. 1: adc2 voltage reference from av+. bit2: tempe: temperature sensor enable bit. 0: internal temperature sensor off. 1: internal temperature sensor on. bit1: biase: adc/dac bias ge nerator enable bit. (must be ?1 ? if using adc2 or dacs). 0: internal bias generator off. 1: internal bias generator on. bit0: refbe: internal refe rence buffer enable bit. 0: internal reference buffer off. 1: internal reference buffer on. internal voltage reference is driven on the vref pin. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - ad2vrs tempe biase refbe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd1 2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 115 11. voltage reference 2 (c8051f064/5/6/7) the internal voltage reference circuit consists of a 1.2 v, temperature stable bandgap voltage reference generator and a gain-of-two output buffer amplifier. the internal reference may be routed to the vref pin as shown in figure 11.1. the maximum load seen by the vref pin must be less than 200 a to agnd. bypass capacitors of 0.1 f and 4.7 f are recomm ended from the vref pin to agnd, as shown in figure 11.1. the reference control register 2, ref2cn (defined in figure 11.2) enables/disables the internal refer- ence generator. the biase bit in ref2cn enables the on-board reference generator while the refbe bit enables the gain-of-two buffer amplifier which drives the vref pin. when disabled, the supply current drawn by the bandgap and buffer amplifier falls to le ss than 1 a (typical) and the output of the buffer amplifier enters a high impedance state. if the internal bandgap is used as the reference voltage generator, biase and refbe must both be set to logic 1. if the internal reference is not used, refbe may be set to logic 0. the electrical specifications for the voltage reference are given in table 11.1. recommended bypass capacitors x2 vref 4.7 f0.1 f refbe biase 1.2v band-gap en + external circuitry figure 11.1. voltage reference functional block diagram
c8051f060/1/2/3/4/5/6/7 116 rev. 1.2 table 11.1. voltage reference electrical characteristics vdd = 3.0 v, av+ = 3.0 v, -40 to +85 c unless otherwise specified parameter conditions min typ max units internal reference (refbe = 1) output voltage 25 c ambient 2.36 2.43 2.48 v vref power supply current 50 a vref short-circuit current 30 ma vref temperature coefficient 15 ppm/c load regulation load = 0 to 200 a to agnd 0.5 ppm/a vref turn-on time 1 4.7 f tantalum, 0.1 f ceramic bypass 2ms vref turn-on time 2 0.1 f ceramic bypass 20 s vref turn-on time 3 no bypass cap 10 s figure 11.2. ref2cn: refere nce control register 2 bits7-4: unused. read = 0000b; write = don?t care. bits2-3: reserved. must write to 00b. bit1: biase: adc/dac bias ge nerator enable bit. (must be ?1 ? if using adc2 or dacs). 0: internal bias generator off. 1: internal bias generator on. bit0: refbe: internal refe rence buffer enable bit. 0: internal reference buffer off. 1: internal reference buffer on. internal voltage reference is driven on the vref pin. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - 0 0 biase refbe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd1 2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 117 12. comparators c8051f06x family of devices include three on-chip programmable voltage comparators, shown in figure 12.1. each comparator offers programmable response time and hysteresis. when assigned to a port pin, the comparator output may be configured as open drain or push-pull, and comparator inputs should be configured as analog inputs (see section ?18.1.5. configuring port 1 and 2 pins as analog inputs? on page 207 ). the comparator may also be used as a reset source (see section ?14.5. comparator0 reset? on page 165 ). the output of a comparator can be polled by soft ware, used as an interrupt source, used as a reset source, and/or routed to a port pin. each comparator can be individually enabl ed and disabled (shutdown). when disabled, the comparator output (if assigned to a port i/o pin via the crossbar) defaults to the logic low state, and its supply curren t falls to less than 1 a. see section ?18.1.1. crossbar pin assignment and allocation? on page 205 for details on configuring the comparator output via the digital crossbar. the figure 12.1. comparator functional block diagram vdd cptncn reset decision tree + - crossbar interrupt logic q q set clr d q q set clr d (synchronizer) cpn + cpn - cpnen cpnout cpnrif cpnfif cpnhyp1 cpnhyp0 cpnhyn1 cpnhyn0 cptnmd cpnrie cpnfie cpnmd1 cpnmd0 cpn rising-edge interrupt flag cpn falling-edge interrupt flag cpn cp0 + cp0 - cp1 + cp1 - cp2 + cp2 - p2.6 p2.7 p2.2 p2.3 p2.4 p2.5 comparator pin assignments gnd cpn interrupt
c8051f060/1/2/3/4/5/6/7 118 rev. 1.2 comparator inputs can be externally driven from -0 .25 v to (vdd) + 0.25 v without damage or upset. the complete electrical specifications for the comparator are given in table 12.1. the comparator response time may be configured in software using the cpnmd1-0 bits in register cpt- nmd (see figure 12.4). selecting a longer response time reduces the amount of power consumed by the comparator. see table 12.1 for complete timi ng and current consumption specifications. the hysteresis of the comparator is software-progr ammable via its comparator control register (cpt- ncn). the user can program both the amount of hysteresis voltage (referred to the input voltage) and the positive and negative-going symmetry of this hysteresis around the threshold voltage. the comparator hysteresis is programmed using bi ts3-0 in the comparator control register cptncn (shown in figure 12.3). the amount of negative hysteresis voltage is determined by the settings of the cpnhyn bits. as shown in figure 12.2, the negative hysteresis can be programmed to three different set- tings, or negative hysteresis can be disabled. in a si milar way, the amount of positive hysteresis is deter- mined by the setting the cpnhyp bits. positive hysteresis voltage (programmed with cpnhyp bits) negative hysteresis voltage (programmed by cpnhyn bits) vin- vin+ inputs circuit configuration + _ cpn+ cpn- cpn vin+ vin- out v oh positive hysteresis disabled maximum positive hysteresis negative hysteresis disabled maximum negative hysteresis output v ol figure 12.2. comparat or hysteresis plot
c8051f060/1/2/3/4/5/6/7 rev. 1.2 119 comparator interrupts can be genera ted on either rising- edge and falling-edge outp ut transitions. (for interrupt enable and priority control, see section ?13.3. interrupt handler? on page 151 ). the rising and/or falling -edge interrupts ar e enabled using the comparator?s rising/ falling edge inte rrupt enable bits (cpn- rie and cpnfie) in their respective comparator mode selection register (cptnmd), shown in figure 12.4. these bits allow the user to control wh ich edge (or both) will cause a comparator interrupt. however, the comparator interrupt must also be enab led in the extended interrupt enable register (eie1). the cpnfif flag is set to logic 1 upon a comparator falling-ed ge interrupt, and the cpnrif flag is set to logic 1 upon the comparator rising-edge interrupt. once set, these bits remain set until cleared by soft- ware. the output state of a comparator can be obtain ed at any time by reading the cpnout bit. a com- parator is enabled by setting its respective cpnen bit to logic 1, and is disabled by clearing this bit to logic 0.upon enabling a comparator, the output of the comp arator is not immediately valid. before using a com- parator as an interrupt or reset source, software should wait for a minimum of the specified ?power-up time? as specified in table 12.1, ?comparato r electrical characteristics,? on page 122. 12.1. comparator inputs the port pins selected as comparator inputs should be configured as analog inputs in the port 2 input con- figuration register (for details on port configuration, see section ?18.1.3. configuring port pins as digital inputs? on page 207 ). the inputs for comparator are on port 2 as follows: comparator input port pin cp0 + p2.6 cp0 - p2.7 cp1 + p2.2 cp1 - p2.3 cp2 + p2.4 cp2 - p2.5
c8051f060/1/2/3/4/5/6/7 120 rev. 1.2 figure 12.3. cptncn: comparator 0, 1, and 2 control register bit7: cpnen: comparat or enable bit. (please see note below.) 0: comparator disabled. 1: comparator enabled. bit6: cpnout: comparator output state flag. 0: voltage on cpn+ < cpn-. 1: voltage on cpn+ > cpn-. bit5: cpnrif: comparator rising-edge interrupt flag. 0: no comparator rising edge interrupt has occurred since this flag was last cleared. 1: comparator rising edge interrupt has occurred. must be cleared by software. bit4: cpnfif: comparator falling-edge interrupt flag. 0: no comparator falling-edge interrupt has occurred since this flag was last cleared. 1: comparator falling-edge interrupt has occurred. must be cleared by software. bits3-2: cpnhyp1-0: comparator positive hysteresis control bits. 00: positive hysteresis disabled. 01: positive hysteresis = 5 mv. 10: positive hysteresis = 10 mv. 11: positive hysteresis = 20 mv. bits1-0: cpnhyn1-0: comparator n egative hysteresis control bits. 00: negative hysteresis disabled. 01: negative hysteresis = 5 mv. 10: negative hysteresis = 10 mv. 11: negative hysteresis = 20 mv. note: upon enabling a comparator, the output of the comparator is not immediately valid. before using a comparator as an interrupt or reset source, software should wait for a minimum of the specified ?power-up time? as specified in table 12.1, ?com parator electrical characteris- tics,? on page 122. r/w r/w r/w r/w r/w r/w r/w r/w reset value cpnen cpnout cpnrif cpnfif cpnhyp1 cpnhyp0 cpnhyn1 cpnhyn0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: cpt0cn: 0x88; cpt1cn: 0x88; cpt2cn: 0x88 sfr pages: cpt0cn: page 1; cpt1cn: page 2; cpt2cn: page 3
c8051f060/1/2/3/4/5/6/7 rev. 1.2 121 figure 12.4. cptnmd: comparator mode selection register bits7-6: unused. read = 00b, write = don?t care. bit 5: cpnrie: comparator rising-edge interrupt enable bit. 0: comparator rising-edge interrupt disabled. 1: comparator rising-edge interrupt enabled. bit 4: cpnfie: comparator falli ng-edge interrupt enable bit. 0: comparator falling-edge interrupt disabled. 1: comparator falling-edge interrupt enabled. bits3-2: unused. read = 00b, write = don?t care. bits1-0: cpnmd1-cpnmd0: comparator mode select these bits select the response time for the comparator. r/w r/w r/w r/w r r r/w r/w reset value - - cpnrie cpnfie - - cpnmd1 cpnmd0 00000010 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: cpt0md: 0x89; cpt1md: 0x89; cpt2md: 0x89 sfr page: cpt0md: page 1; cpt1md: page 2; cpt2md: page 3 mode cpnmd1 cpnmd0 notes 0 0 0 fastest response time 101 - 210 - 311 lowest power consump- tion
c8051f060/1/2/3/4/5/6/7 122 rev. 1.2 table 12.1. comparator electrical characteristics vdd = 3.0 v, -40 to +85 c unless otherwise specified. parameter conditions min typ max units response time, mode 0 cpn+ - cpn- = 100 mv 100 ns cpn+ - cpn- = 10 mv 250 ns response time, mode 1 cpn+ - cpn- = 100 mv 175 ns cpn+ - cpn- = 10 mv 500 ns response time, mode 2 cpn+ - cpn- = 100 mv 320 ns cpn+ - cpn- = 10 mv 1100 ns response time, mode 3 cpn+ - cpn- = 100 mv 1050 ns cpn+ - cpn- = 10 mv 5200 ns common-mode rejection ratio 1.5 4 mv/v positive hysteresis 1 cpnhyp1-0 = 00 0 1 mv positive hysteresis 2 cpnhyp1-0 = 01 3 5 7 mv positive hysteresis 3 cpnhyp1-0 = 10 7 10 15 mv positive hysteresis 4 cpnhyp1-0 = 11 15 20 25 mv negative hysteresis 1 cpnhyn1-0 = 00 0 1 mv negative hysteresis 2 cpnhyn1-0 = 01 3 5 7 mv negative hysteresis 3 cpnhyn1-0 = 10 7 10 15 mv negative hysteresis 4 cpnhyn1-0 = 11 15 20 25 mv inverting or non-inverting input voltage range -0.25 vdd + 0.25 v input capacitance 7 pf input bias current -5 0.001 +5 na input offset voltage -5 +5 mv power supply power supply rejection 0.1 1 mv/v power-up time 10 s supply current at dc mode 0 7.6 a mode 1 3.2 a mode 2 1.3 a mode 3 0.4 a
c8051f060/1/2/3/4/5/6/7 rev. 1.2 123 13. cip-51 microcontroller the mcu system controller core is the cip-51 microcon troller. the cip-51 is fully compatible with the mcs-51? instruction set; standard 803x/805x assemble rs and compilers can be used to develop soft- ware. the mcu family has a superset of all the peripherals included with a standard 8051. included are five 16-bit counter/timers (see description in section 24 ), two full-duplex uarts (see description in section 22 and section 23 ), 256 bytes of internal ram, 128 byte spec ial function register (sfr) address space (see section 13.2.6 ), and 59/24 general-purpose i/o pins (see description in section 18 ). the cip-51 also includes on-chip debug hardware (see description in section 26 ), and interfaces directly with the mcu?s analog and digital subsystems providing a complete da ta acquisition or control- system solution in a single integrated circuit. - fully compatible with mcs-51 instruction set - 25 mips peak throughput with 25 mhz clock - 0 to 25 mhz clock frequency - 256 bytes of internal ram - 59/24 general-purpose i/o pins - extended interrupt handler - reset input - power management modes - on-chip debug logic - program and data memory security
c8051f060/1/2/3/4/5/6/7 124 rev. 1.2 the cip-51 microcontroller core implements the standard 8051 organization and peripherals as well as additional custom peripherals and functions to extend its capability (s ee figure 13.1 for a block diagram). the cip-51 includes the following features: performance the cip-51 employs a pipelined architecture that grea tly increases its instruction throughput over the stan- dard 8051 architecture. in a standar d 8051, all instructions except fo r mul and div take 12 or 24 system clock cycles to execute, and usually have a maximu m system clock of 12 mhz. by contrast, the cip-51 core executes 70% of its instructions in one or tw o system clock cycles, with no instructions taking more than eight system clock cycles. with the cip-51's maximum system clock at 25 mhz, it has a peak throughput of 25 mips. the cip-51 has a total of 109 instructions. the table below shows the to tal number of instructions that require each execu- tion time. clocks to execute 1 22/333/444/55 8 number of instructions 26505147 3 1 2 1 figure 13.1. cip-51 block diagram data bus tmp1 tmp2 prgm. address reg. pc incrementer alu psw data bus data bus memory interface mem_address d8 pipeline buffer data pointer interrupt interface system_irqs debug_irq mem_control control logic a16 program counter (pc) stop clock reset idle power control register data bus sfr bus interface sfr_address sfr_control sfr_write_data sfr_read_data d8 d8 b register d8 d8 accumulator d8 d8 d8 d8 d8 d8 d8 d8 mem_write_data mem_read_data d8 sram address register sram (256 x 8) d8 stack pointer d8
c8051f060/1/2/3/4/5/6/7 rev. 1.2 125 programming and debugging support a jtag-based serial interface is provided for in- system programming of the flash program memory and communication with on-chip debug support logic. the re-programmable flash can also be read and changed a single byte at a time by the applicatio n software using the movc and movx instructions. this feature allows program memory to be used for non-volatile data storage as well as updating program code under software control. the on-chip debug support logic facilitates full speed in-circuit debugging, a llowing the setting of hardware breakpoints and watch points, starting, stopping and single stepping through program execution (including interrupt service routines), examination of the program' s call stack, and reading/wr iting the contents of reg- isters and memory. this method of on-chip debug is completely non-intrusive and non-invasive, requiring no ram, stack, timers, or other on-chip resources. the cip-51 is support ed by development tools from silicon labs and third party vendors. silicon labs pro- vides an integrated development environment (ide) whic h interfaces to the cip-51 via its jtag port to pro- vide fast and efficient in-system device programmin g and debugging. third party macro assemblers and c compilers are also available. 13.1. instruction set the instruction set of the cip-51 system controller is fully compatible with the standard mcs-51? instruc- tion set; standard 8051 development tools can be used to develop software for the cip-51. all cip-51 instructions are the binary and fu nctional equivalent of their mcs-51? counterparts, including opcodes, addressing modes and effect on psw flags. however, in struction timing is different than that of the stan- dard 8051. 13.1.1. instruction and cpu timing in many 8051 implementations, a distinction is ma de between machine cycles and clock cycles, with machine cycles varying from 2 to 12 clock cycles in length. however, the cip-51 implementation is based solely on clock cycle timing. all instructio n timings are specified in terms of clock cycles. due to the pipelined architecture of the cip-51, most instructions execute in the same number of clock cycles as there are program bytes in the instruction. conditional branch instruct ions take one less clock cycle to complete when the branch is not taken as o pposed to when the branch is taken. table 13.1 is the cip-51 instruction set summary, which includes the mnemonic, number of bytes, and number of clock cycles for each instruction. 13.1.2. movx instruction and program memory in the cip-51, the movx instruction serves three purposes: accessing on-chip xram, accessing off-chip xram, and writing to on-chip program flash memory. the flash access feature provides a mechanism for user software to update program code and use the program memory space for non-volatile data storage (see section ?16. flash memory? on page 177 ). the external memory interface provides a fast access to off-chip xram (or memory-mapped peripherals) via the movx instruction. refer to section ?17. external data memory interface and on-chip xram? on page 187 for details.
c8051f060/1/2/3/4/5/6/7 126 rev. 1.2 table 13.1. cip-51 instruction set summary mnemonic description bytes clock cycles arithmetic operations add a, rn add register to a 1 1 add a, direct add direct byte to a 2 2 add a, @ri add indirect ram to a 1 2 add a, #data add immediate to a 2 2 addc a, rn add register to a with carry 1 1 addc a, direct add direct byte to a with carry 2 2 addc a, @ri add indirect ram to a with carry 1 2 addc a, #data add immediate to a with carry 2 2 subb a, rn subtract register from a with borrow 1 1 subb a, direct subtract direct byte from a with borrow 2 2 subb a, @ri subtract indirect ram from a with borrow 1 2 subb a, #data subtract imme diate from a with borrow 2 2 inc a increment a 1 1 inc rn increment register 1 1 inc direct increment direct byte 2 2 inc @ri increment indirect ram 1 2 dec a decrement a 1 1 dec rn decrement register 1 1 dec direct decrement direct byte 2 2 dec @ri decrement indirect ram 1 2 inc dptr increment data pointer 1 1 mul ab multiply a and b 1 4 div ab divide a by b 1 8 da a decimal adjust a 1 1 logical operations anl a, rn and register to a 1 1 anl a, direct and direct byte to a 2 2 anl a, @ri and indirect ram to a 1 2 anl a, #data and immediate to a 2 2 anl direct, a and a to direct byte 2 2 anl direct, #data and immediate to direct byte 3 3 orl a, rn or register to a 1 1 orl a, direct or direct byte to a 2 2 orl a, @ri or indirect ram to a 1 2 orl a, #data or immediate to a 2 2 orl direct, a or a to direct byte 2 2 orl direct, #data or immediate to direct byte 3 3 xrl a, rn exclusive-or register to a 1 1 xrl a, direct exclusive-or direct byte to a 2 2 xrl a, @ri exclusive-or indirect ram to a 1 2 xrl a, #data exclusive-or immediate to a 2 2 xrl direct, a exclusive-or a to direct byte 2 2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 127 xrl direct, #data exclusive-or immediate to direct byte 3 3 clr a clear a 1 1 cpl a complement a 1 1 rl a rotate a left 1 1 rlc a rotate a left through carry 1 1 rr a rotate a right 1 1 rrc a rotate a right through carry 1 1 swap a swap nibbles of a 1 1 data transfer mov a, rn move register to a 1 1 mov a, direct move direct byte to a 2 2 mov a, @ri move indirect ram to a 1 2 mov a, #data move immediate to a 2 2 mov rn, a move a to register 1 1 mov rn, direct move direct byte to register 2 2 mov rn, #data move immediate to register 2 2 mov direct, a move a to direct byte 2 2 mov direct, rn move register to direct byte 2 2 mov direct, direct move direct byte to direct byte 3 3 mov direct, @ri move indirect ram to direct byte 2 2 mov direct, #data move immediate to direct byte 3 3 mov @ri, a move a to indirect ram 1 2 mov @ri, direct move direct byte to indirect ram 2 2 mov @ri, #data move immediate to indirect ram 2 2 mov dptr, #data16 load dptr with 16-bit constant 3 3 movc a, @a+dptr move code byte relative dptr to a 1 3 movc a, @a+pc move code byte relative pc to a 1 3 movx a, @ri move external data (8-bit address) to a 1 3 movx @ri, a move a to external data (8-bit address) 1 3 movx a, @dptr move external data (16-bit address) to a 1 3 movx @dptr, a move a to external data (16-bit address) 1 3 push direct push direct byte onto stack 2 2 pop direct pop direct byte from stack 2 2 xch a, rn exchange register with a 1 1 xch a, direct exchange direct byte with a 2 2 xch a, @ri exchange indirect ram with a 1 2 xchd a, @ri exchange low nibble of indirect ram with a 1 2 boolean manipulation clr c clear carry 1 1 clr bit clear direct bit 2 2 setb c set carry 1 1 setb bit set direct bit 2 2 cpl c complement carry 1 1 cpl bit complement direct bit 2 2 anl c, bit and direct bit to carry 2 2 table 13.1. cip-51 instruction set summary (continued) mnemonic description bytes clock cycles
c8051f060/1/2/3/4/5/6/7 128 rev. 1.2 anl c, /bit and complement of direct bit to carry 2 2 orl c, bit or direct bit to carry 2 2 orl c, /bit or complement of direct bit to carry 2 2 mov c, bit move direct bit to carry 2 2 mov bit, c move carry to direct bit 2 2 jc rel jump if carry is set 2 2/3 jnc rel jump if carry is not set 2 2/3 jb bit, rel jump if direct bit is set 3 3/4 jnb bit, rel jump if direct bit is not set 3 3/4 jbc bit, rel jump if direct bit is set and clear bit 3 3/4 program branching acall addr11 absolute subroutine call 2 3 lcall addr16 long subroutine call 3 4 ret return from subroutine 1 5 reti return from interrupt 1 5 ajmp addr11 absolute jump 2 3 ljmp addr16 long jump 3 4 sjmp rel short jump (relative address) 2 3 jmp @a+dptr jump indirect relative to dptr 1 3 jz rel jump if a equals zero 2 2/3 jnz rel jump if a does not equal zero 2 2/3 cjne a, direct, rel compare direct byte to a and jump if not equal 3 3/4 cjne a, #data, rel compare immediate to a and jump if not equal 3 3/4 cjne rn, #data, rel compare immediate to register and jump if not equal 33/4 cjne @ri, #data, rel compare immediate to indirect and jump if not equal 34/5 djnz rn, rel decrement regist er and jump if not zero 2 2/3 djnz direct, rel decrement direct byte and jump if not zero 3 3/4 nop no operation 1 1 table 13.1. cip-51 instruction set summary (continued) mnemonic description bytes clock cycles
c8051f060/1/2/3/4/5/6/7 rev. 1.2 129 notes on registers, operands and addressing modes: rn - register r0-r7 of the currently selected register bank. @ri - data ram location addressed indirectly through r0 or r1. rel - 8-bit, signed (two?s complement) offset relative to the first byte of the following instruction. used by sjmp and all conditional jumps. direct - 8-bit internal data location?s address. this could be a direct-access data ram location (0x00- 0x7f) or an sfr (0x80-0xff). #data - 8-bit constant #data16 - 16-bit constant bit - direct-accessed bit in data ram or sfr addr11 - 11-bit destination address used by acall and ajmp. the destination mu st be within the same 2k-byte page of program memory as the first byte of the following instruction. addr16 - 16-bit destination address used by lcall a nd ljmp. the destination may be anywhere within the 64k-byte program memory space. there is one unused opcode (0xa5) that performs the same function as nop. all mnemonics copyrighted ? intel corporation 1980.
c8051f060/1/2/3/4/5/6/7 130 rev. 1.2 13.2. memory organization the memory organization of the cip-51 system controller is similar to that of a standard 8051. there are two separate memory spaces: program memory and data memory. program and data memory share the same address space but are accessed via different in struction types. there are 256 bytes of internal data memory and 64 k bytes (c8051f060/1/2/3/4/5) or 32 k bytes (c8051f066/7) of internal program memory address space implemented within the cip-51. the ci p-51 memory organization is shown in figure 13.2. 13.2.1. program memory the cip-51 has a 64 k byte program memory space. the c8051f060/1/2/3/4/5 devices implement 64 k bytes of this program memory space as in-system re-programmable flash memory, organized in a contig- uous block from addresses 0x0000 to 0xffff. note: 1024 bytes (0xfc00 to 0xffff) of this memory are reserved, and are not available for user program stor age. the c8051f066/7 implement 32 k bytes of this program memory space as in-system re-programmable flas h memory, organized in a contiguous block from addresses 0x0000 to 0x7fff. program memory is normally assumed to be read-only (using the movc instruction). however, the cip-51 can write to program memory by enabling flash writes, and using the movx instruction. this feature pro- vides a mechanism for the cip-51 to update program code and use the program memory space for non- volatile data storage. refer to section ?16. flash memory? on page 177 for further details. program/data memory (flash) (direct and indirect addressing) 0x00 0x7f upper 128 ram (indirect addressing only) 0x80 0xff special function registers (direct addressing only) data memory (ram) general purpose registers 0x1f 0x20 0x2f bit addressable lower 128 ram (direct and indirect addressing) 0x30 internal data address space external data address space xram - 4096 bytes (accessable using movx instruction) 0x0000 0x0fff off-chip xram space (c8051f060/2/4/6 only) 0x1000 0xffff flash (in-system programmable in 512 byte sectors) 0x0000 0xffff reserved 0xfc00 0xfbff scrachpad memory (data only) 0x1007f 0x10000 up to 256 sfr pages 1 3 0 2 c8051f060/1/2/3/4/ 5 flash (in-system programmable in 512 byte sectors) 0x0000 0xffff reserved 0x8000 0x7fff scrachpad memory (data only) 0x1007f 0x10000 c8051f066/7 figure 13.2. memory map
c8051f060/1/2/3/4/5/6/7 rev. 1.2 131 13.2.2. data memory the cip-51 implements 256 bytes of internal ram map ped into the data memory space from 0x00 through 0xff. the lower 128 bytes of data memory are used for general purpose registers and scratch pad mem- ory. either direct or indirect addressing may be us ed to access the lower 128 bytes of data memory. loca- tions 0x00 through 0x1f are addressa ble as four banks of general purpose registers, each bank consisting of eight byte-wide registers. the next 16 bytes, loca tions 0x20 through 0x2f, may either be addressed as bytes or as 128 bit locations accessible with the direct addressing mode. the upper 128 bytes of data memory are accessible only by indirect addressing. this region occupies the same address space as the special function register s (sfrs) but is physically separate from the sfr space. the addressing mode used by an instructio n when accessing locations above 0x7f determines whether the cpu accesses the upper 128 bytes of data memory space or the sfrs. instructions that use direct addressing above 0x7f will access the sfr spac e. instructions using in direct addressing above 0x7f access the uppe r 128 bytes of data memory. figure 13.2 illu strates the data memo ry organization of the cip-51. 13.2.3. general purpose registers the lower 32 bytes of data memory, locations 0x00 through 0x1f, may be addressed as four banks of gen- eral-purpose registers. each bank consists of ei ght byte-wide registers designated r0 through r7. only one of these banks may be enabled at a time. two bi ts in the program status word, rs0 (psw.3) and rs1 (psw.4), select the active register bank (see descripti on of the psw in figure 13.1 6). this allows fast con- text switching when entering subroutines and interr upt service routines. indi rect addressing modes use registers r0 and r1 as index registers. 13.2.4. bit addressable locations in addition to direct access to data memory organized as bytes, the sixteen data memory locations at 0x20 through 0x2f are also accessible as 128 individually addressable bits. each bit has a bit address from 0x00 to 0x7f. bit 0 of the byte at 0x20 has bit address 0x00 while bit 7 of the byte at 0x20 has bit address 0x07. bit 7 of the byte at 0x2f has bit address 0x7f. a bit access is distinguished from a full byte access by the type of instruction used (a bit source or destinati on operand as opposed to a byte source or destina- tion). the mcs-51? assembly language allows an alternate notation for bit addressing of the form xx.b where xx is the byte address and b is the bit position within the byte. for example, the instruction: mov c, 22.3h moves the boolean value at 0x13 (bit 3 of the byte at location 0x22) into the carry flag. 13.2.5. stack a programmer's stack can be located anywhere in the 256 byte data memory. the stack area is designated using the stack pointer (sp, addres s 0x81) sfr. the sp will point to the last location used. the next value pushed on the stack is placed at sp+1 and then sp is incremented. a reset init ializes the stack pointer to location 0x07; therefore, the first value pushed on th e stack is placed at location 0x08, which is also the first register (r0) of register bank 1. thus, if more than one register bank is to be used, the sp should be initialized to a location in the data memory not being used for data storage. the stack depth can extend up to 256 bytes. the mcus also have built-in hardware for a stack record which is accessed by the debug logic. the stack record is a 32-bit shift register, where each push or increment sp pushes one record bit onto the register,
c8051f060/1/2/3/4/5/6/7 132 rev. 1.2 and each call pushes two record bits onto the register. (a pop or decrement sp pops one record bit, and a ret pops two record bits, also.) the stack record circuitry can also detect an overflow or underflow on the 32-bit shift register, and can notify the d ebug software even with the mcu running at speed. 13.2.6. special function registers the direct-access data memory locations from 0x80 to 0xff constitute the special function registers (sfrs). the sfrs provide control and data exchang e with the cip-51's resources and peripherals. the cip-51 duplicates the sfrs found in a typical 805 1 implementation as well as implementing additional sfrs used to configure and access the sub-systems uni que to the mcu. this allows the addition of new functionality while retaining compatibility wi th the mcs-51? instru ction set. table 13.2 lists the sfrs implemented in the cip-51 system controller. the sfrs are accessed whenever the direct addressing mode is used to access memory locations from 0x80 to 0xff. sfrs with addresses ending in 0x0 or 0x8 (e.g. p0, tcon, p1, scon, ie, etc.) are bit- addressable as well as byte-addressable. all ot her sfrs are byte-addressable only. unoccupied addresses in the sfr space are rese rved for future use. accessing t hese areas will have an indeterminate effect and should be avoided. refer to the corr esponding pages of the datasheet, as indicated in table 13.3, for a detailed description of each register. 13.2.6.1.sfr paging the cip-51 features sfr paging, allowing the device to map many sfrs into the 0x80 to 0xff memory address space. the sfr memory space has 256 pages . in this way, each memory location from 0x80 to 0xff can access up to 256 sfrs. the c8051f06x family of devices utilizes five sfr pages: 0, 1, 2, 3, and f. sfr pages are selected using the special functi on register page select ion register, sfrpage (see figure 13.10). the procedure for reading and writing an sfr is as follows: 1. select the appropriate sfr page number using the sfrpage register. 2. use direct accessing mode to read or write t he special function register (mov instruction). 13.2.6.2.interrupt s and sfr paging when an interrupt occurs, the sfr p age register will automatically switch to the sfr page containing the flag bit that caused the interrupt. the automatic sfr page switch function conveniently removes the bur- den of switching sfr pages from the interrupt service ro utine. upon execut ion of the reti instruction, the sfr page is automatically restored to the sfr page in use prior to the interrupt. this is accomplished via a three-byte sfr page stack . the top byte of the stack is sfrp age, the current sfr page. the second byte of the sfr page stack is sfrnext. the third, or bottom byte of the sfr page stack is sfrlast. on interrupt, the current sfrpage value is pushed to the sfrnext byte, and the value of sfrnext is pushed to sfrlast. hardware then loads sfrpage with the sfr page containing the flag bit associated with the interrupt. on a return from interrupt, the sfr page stack is popped resulting in the value of sfrn- ext returning to the sfrpage register, thereby restor ing the sfr page context without software interven- tion. the value in sfrlast (0x00 if there is no sfr page value in the bottom of the stack) of the stack is placed in sfrnext register. if desired, the valu es stored in sfrnext and sfrlast may be modified during an interrupt, enabling the cpu to return to a different sfr page upon execution of the reti instruc- tion (on interrupt exit). modifying registers in the sfr page stack does not cause a push or pop of the stack. only interrupt calls and returns will cause pu sh/pop operations on the sfr page stack.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 133 automatic hardware switching of the sfr page on interrupts may be enabled or disabled as desired using the sfr automatic page control enab le bit located in the sfr page control register (sfrpgcn). this function defaults to ?enabled? upon reset. in this way, th e autoswitching function will be enabled unless dis- abled in software. a summary of the sfr locations (address and sfr page) is provided in table 13.2. in the form of an sfr memory map. each memory location in the map has an sfr page row, denoting the page in which that sfr resides. note that certain sfrs are accessible from all sfr pages, and are denoted by the ? (all pages) ? designation. for example, the port i/o registers p0, p1, p2, and p3 all have the ? (all pages) ? designation, indicating these sfrs are accessible from all sfr pages regardless of the sfrpage register value. sfrnext sfrpage sfrlast cip-51 interrupt logic sfrpgcn bit figure 13.3. sfr page stack
c8051f060/1/2/3/4/5/6/7 134 rev. 1.2 13.2.6.3.sfr page stack example the following is an example that shows the operation of the sfr page stack during interrupts. in this example, the sfr page cont rol is left in the default enabled state (i.e., sfrpgen = 1), and the cip-51 is executing in-line code that is writing values to port 5 (sfr ?p 5?, located at address 0xd8 on sfr page 0x0f). the device is also using the program mable counter array (pca) and the 10-bit adc (adc2) window comparator to monitor a voltage. the pca is timing a critical control function in its interrupt service routine (isr), so its interrupt is enabled and is set to high priority. the adc2 is monitoring a voltage that is less important, but to minimize the software overhead its window comparator is being used with an associ- ated isr that is set to low priority. at this point, the sfr page is set to access the port 5 sfr (sfrpage = 0x0f). see figure 13.4 below. 0x0f (port 5) sfrpage sfrlast sfrnext sfr page stack sfr's figure 13.4. sfr page stack while using sfr page 0x0f to access port 5
c8051f060/1/2/3/4/5/6/7 rev. 1.2 135 while cip-51 executes in-line code (writing values to port 5 in this example), adc2 window comparator interrupt occurs. the cip-51 vectors to the adc2 window co mparator isr and pushes the current sfr page value (sfr page 0x0f) into sfrnext in the sfr page stack. the sfr page needed to access adc2?s sfrs is then automatically placed in the sfrpage register (sfr page 0x02). sfrpage is con- sidered the ?top? of the sfr page stack. software can now access the adc2 sfrs. software may switch to any sfr page by writing a new value to the sfrpage register at any time during the adc2 isr to access sfrs that are not on sfr page 0x02. see figure 13.5 below. 0x02 (adc2) 0x0f (port 5) sfrpage sfrlast sfrnext sfrpage pushed to sfrnext sfr page 0x02 automatically pushed on stack in sfrpage on adc2 interrupt figure 13.5. sfr page stack after adc2 window comparator interrupt occurs
c8051f060/1/2/3/4/5/6/7 136 rev. 1.2 while in the adc2 isr, a pca interrupt occurs . recall the pca interrupt is configured as a high priority interrupt, while the adc2 inte rrupt is configured as a low priority interrupt. thus , the cip-51 will now vector to the high priority pca isr. upon doing so, the cip-51 will automatically plac e the sfr page needed to access the pca?s special function registers into the sfrpage register, sfr page 0x00. the value that was in the sfrpage register before the pca interrupt (sfr page 2 for adc2) is pushed down the stack into sfrnext. likewise, the value that was in the sfrnext register before the pca interrupt (in this case sfr page 0x0f for port 5) is pushed down to the sfrlast register, the ? bottom? of the stack. note that a value st ored in sfrlast (via a previo us software write to the sfrl ast register) will be overwritten. see figure 13.6 below. 0x00 (pca) 0x02 (adc2) 0x0f (port 5) sfrpage sfrlast sfrnext sfr page 0x00 automatically pushed on stack in sfrpage on pca interrupt sfrpage pushed to sfrnext sfrnext pushed to sfrlast figure 13.6. sfr page stack upon pca interrupt occurring during an adc2 isr
c8051f060/1/2/3/4/5/6/7 rev. 1.2 137 on exit from the pca interrupt service routine, the cip-51 will retu rn to the adc2 window comparator isr. on execution of the reti inst ruction, sfr page 0x00 used to access the pca registers will be auto- matically popped off of the sfr pa ge stack, and the contents of th e sfrnext register will be moved to the sfrpage register. software in the adc2 isr can co ntinue to access sfrs as it did prior to the pca interrupt. likewise, the contents of sfrlast are mo ved to the sfrnext register. recall this was the sfr page value 0x0f being used to access port 5 before the adc2 interrupt occurred. see figure 13.7 below. 0x02 (adc2) 0x0f (port 5) sfrpage sfrlast sfrnext sfr page 0x00 automatically popped off of the stack on return from interrupt sfrnext popped to sfrpage sfrlast popped to sfrnext figure 13.7. sfr page stack upon return from pca interrupt
c8051f060/1/2/3/4/5/6/7 138 rev. 1.2 on the execution of the reti instruction in the adc2 window comparator isr, the value in sfrpage register is overwritten with the co ntents of sfrnext. the cip-51 may now access the port 5 sfr bits as it did prior to the interrupts occurring. see figure 13.8 below. note that in the above example, all three bytes in the sfr page stack are accessible via the sfrpage, sfrnext, and sfrlast special function registers. if the stack is altered wh ile servicing an interrupt, it is possible to return to a different sfr page upon interrup t exit than selected prior to the interrupt call. direct access to the sfr page stack can be useful to enable real-time operating systems to control and manage context switching between multiple tasks. push operations on the sfr page stack only occur on interrupt service, and pop operations only occur on interrupt exit (execution on the reti instruction). the automatic switching of the sfrpage and operation of the sfr page stack as described above can be disabled in software by clearing the sfr automatic page enable bit (sfrpgen) in the sfr page control register (sfrpgcn). see figure 13.9. 0x0f (port 5) sfrpage sfrlast sfrnext sfr page 0x02 automatically popped off of the stack on return from interrupt sfrnext popped to sfrpage figure 13.8. sfr page stack upon return from adc2 window interrupt
c8051f060/1/2/3/4/5/6/7 rev. 1.2 139 figure 13.9. sfrpgcn: sfr page control register bits7-1: reserved. bit0: sfrpgen: sfr automatic page control enable. upon interrupt, the c8051 core will vector to the specified interr upt service routine and automatically switch the sfr page to the corresponding peripheral or function?s sfr page. this bit is used to control this autopaging function. 0: sfr automatic paging disabled. c8051 co re will not automatically change to the appro- priate sfr page (i.e., the sfr page that cont ains the sfrs for the peripheral/function that was the source of the interrupt). 1: sfr automatic paging enabl ed. upon inte rrupt, the c8051 will switch the sfr page to the page that contains the sfrs for the periphera l or function that is the source of the inter- rupt. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - - - - sfrpgen 00000001 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x96 f figure 13.10. sfrpage: sfr page register bits7-0: sfr page bits: byte represents the sf r page the c8051 mcu uses when reading or modifying sfrs. write: sets the sfr page. read: byte is the sfr page the c8051 mcu is using. when enabled in the sfr page control regist er (sfrpgcn), the c8051 will automatically switch to the sfr page that contains the sfrs of the corresponding peripheral/function that caused the interrupt, and return to the previous sfr page upon return from interrupt (unless sfr stack was altered before a returning from the interrupt). sfrpage is the top byte of the sfr page stack, and push/pop events of this stack are caused by interrupts (and not by reading/writing to the sfrpage register) r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x84 all pages
c8051f060/1/2/3/4/5/6/7 140 rev. 1.2 figure 13.11. sfrnext: sfr next register bits7-0: sfr page stack bits: sfr page context is retained upon interrupts/return from interrupts in a 3 byte sfr page stack: sfrpage is the fi rst entry, sfrnext is the second, and sfr- last is the third entry. the sfr stack bytes may be used to alter the context in the sfr page stack, and will not cause the stack to ?push? or ?pop?. only interrupts an d return from interrupt cause push and pop the sfr page stack. write: sets the sfr page contained in the se cond byte of the sfr stack. this will cause the sfrpage sfr to have this sfr page value upon a return from interrupt. read: returns the value of the sfr page contained in the second byte of the sfr stack. this is the value that will go to the sfr pa ge register upon a re turn from interrupt. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x85 all pages figure 13.12. sfrlast: sfr last register bits7-0: sfr page stack bits: sfr page context is retained upon interrupts/return from interrupts in a 3 byte sfr page stack: sfrpage is the fi rst entry, sfrnext is the second, and sfr- last is the third entry. the sfr stack bytes may be used to alter the context in the sfr page stack, and will not cause the stack to ?push? or ?pop?. only interrupts an d return from interrupt cause push and pop the sfr page stack. write: sets the sfr page in the last entry of the sfr stack. this will cause the sfrnext sfr to have this sfr page value upon a return from interrupt. read: returns the value of the sfr page contained in the last entry of the sfr stack. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x86 all pages
c8051f060/1/2/3/4/5/6/7 rev. 1.2 141 table 13.2. special function register (sfr) memory map a d d r e s s sfr p a g e 0(8) 1(9) 2(a) 3(b) 4(c) 5(d) 6(e) 7(f) f8 0 1 2 3 f spi0cn can0cn dma0cf p7 pca0l dma0ctl pca0h dma0cth pca0cpl0 dma0csl pca0cph0 dma0csh pca0cpl1 dma0bnd pca0cph1 dma0isw wdtcn (all pages) f0 0 1 2 3 f b (all pages) eip1 (all pages) eip2 (all pages) e8 0 1 2 3 f adc0cn adc1cn adc2cn p6 pca0cpl2 pca0cph2 pca0cpl3 pca0cph3 pca0cpl4 pca0cph4 rstsrc e0 0 1 2 3 f acc (all pages) pca0cpl5 xbr0 pca0cph5 xbr1 xbr2 xbr3 eie1 (all pages) eie2 (all pages) d8 0 1 2 3 f pca0cn can0datl dma0cn p5 pca0md can0dath dma0dal pca0cpm0 can0adr dma0dah pca0cpm1 can0tst dma0dsl pca0cpm2 dma0dsh pca0cpm3 dma0ipt pca0cpm4 dma0idt pca0cpm5 d0 0 1 2 3 f psw (all pages) ref0cn ref1cn ref2cn dac0l dac1l dac0h dac1h dac0cn dac1cn c8 0 1 2 3 f tmr2cn tmr3cn tmr4cn p4 tmr2cf tmr3cf tmr4cf rcap2l rcap3l rcap4l rcap2h rcap3h rcap4h tmr2l tmr3l tmr4l tmr2h tmr3h tmr4h smb0cr c0 0 1 2 3 f smb0cn can0sta smb0sta smb0dat smb0adr adc0gtl adc2gtl adc0gth adc2gth adc0ltl adc2ltl adc0lth adc2lth b8 0 1 2 3 f ip (all pages) saden0 amx2cf adc0cpt amx0sl amx2sl adc0ccf adc0cf adc1cf adc2cf adc0l adc1l adc2l adc0h adc1h adc2h 0(8) 1(9) 2(a) 3(b) 4(c) 5(d) 6(e) 7(f)
c8051f060/1/2/3/4/5/6/7 142 rev. 1.2 b0 0 1 2 3 f p3 (all pages) flscl flacl a8 0 1 2 3 f ie (all pages) saddr0 p1mdin p2mdin a0 0 1 2 3 f p2 (all pages) emi0tc emi0cn emi0cf p0mdout p1mdout p2mdout p3mdout 98 0 1 2 3 f scon0 scon1 sbuf0 sbuf1 spi0cfg spi0dat p4mdout spi0ckr p5mdout p6mdout p7mdout 90 0 1 2 3 f p1 (all pages) ssta0 sfrpgcn clksel 88 0 1 2 3 f tcon cpt0cn cpt1cn cpt2cn tmod cpt0md cpt1md cpt2md tl0 oscicn tl1 oscicl th0 oscxcn th1 ckcon psctl 80 0 1 2 3 f p0 (all pages) sp (all pages) dpl (all pages) dph (all pages) sfrpage (all pages) sfrnext (all pages) sfrlast (all pages) pcon (all pages) table 13.2. special function register (sfr) memory map 0(8) 1(9) 2(a) 3(b) 4(c) 5(d) 6(e) 7(f)
c8051f060/1/2/3/4/5/6/7 rev. 1.2 143 table 13.3. special function registers sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no. b 0xf0 all pages b register page 150 acc 0xe0 all pages accumulator page 150 adc0ccf 0xbb f adc0 calibration coefficient page 68 adc0cf 0xbc 0 adc0 configuration page 58 adc0cn 0xe8 0 adc0 control page 60 adc0cpt 0xba f adc0 calibration pointer page 68 adc0gth 0xc5 0 adc0 greater-than high page 69 adc0gtl 0xc4 0 adc0 greater-than low page 69 adc0h 0xbf 0 adc0 data word high page 63 adc0l 0xbe 0 adc0 data word low page 63 adc0lth 0xc7 0 adc0 less-than high page 70 adc0ltl 0xc6 0 adc0 less-than low page 70 adc1cf 0xbc 1 adc1 configuration page 59 adc1cn 0xe8 1 adc1 control page 61 adc1h 0xbf 1 adc1 data word high page 65 adc1l 0xbe 1 adc1 data word low page 65 adc2cf 0xbc 2 adc2 configuration page 94 *5 adc2cn 0xe8 2 adc2 control page 96 *5 adc2gth 0xc5 2 adc2 greater-than high page 97 *5 adc2gtl 0xc4 2 adc2 greater-than low page 97 *5 adc2h 0xbf 2 adc2 data word high page 95 *5 adc2l 0xbe 2 adc2 data word low page 95 *5 adc2lth 0xc7 2 adc2 less-than high page 98 *5 adc2ltl 0xc6 2 adc2 less-than low page 98 *5 amx0sl 0xbb 0 adc0 multiplexer channel select page 57 amx2cf 0xba 2 adc2 analog mu ltiplexer configuration page 94 *5 amx2sl 0xbb 2 adc2 analog multiplexer channel select page 93 *5 can0adr 0xda 1 can0 address page 232 *5 can0cn 0xf8 1 can0 control page 232 *5 can0dath 0xd9 1 can0 data high page 231 *5 can0datl 0xd8 1 can0 data low page 231 *5 can0sta 0xc0 1 can0 status page 233 *5 can0tst 0xdb 1 can0 test page 233 *5 ckcon 0x8e 0 clock control page 293 clksel 0x97 f oscillator clock se lection register page 173 cpt0cn 0x88 1 comparator 0 control page 120 cpt0md 0x89 1 comparator 0 configuration page 121 cpt1cn 0x88 2 comparator 1 control page 120 cpt1md 0x89 2 comparator 1 configuration page 121 cpt2cn 0x88 3 comparator 2 control page 120
c8051f060/1/2/3/4/5/6/7 144 rev. 1.2 cpt2md 0x89 3 comparator 2 configuration page 121 dac0cn 0xd4 0 dac0 control page 106 *5 dac0h 0xd3 0 dac0 high page 105 *5 dac0l 0xd2 0 dac0 low page 105 *5 dac1cn 0xd4 1 dac1 control page 108 *5 dac1h 0xd3 1 dac1 high page 107 *5 dac1l 0xd2 1 dac1 low page 107 *5 dma0bnd 0xfd 3 dma0 instruction boundary page 83 dma0cf 0xf8 3 dma0 configuration page 81 dma0cn 0xd8 3 dma0 control page 80 dma0csh 0xfc 3 dma0 repeat counter status high byte page 85 dma0csl 0xfb 3 dma0 repeat counter status low byte page 85 dma0cth 0xfa 3 dma0 repeat counter limit high byte page 85 dma0ctl 0xf9 3 dma0 repeat counter limit low byte page 85 dma0dah 0xda 3 dma0 data address beginning high byte page 84 dma0dal 0xd9 3 dma0 data addr ess beginning low byte page 84 dma0dsh 0xdc 3 dma0 data address pointer high byte page 84 dma0dsl 0xdb 3 dma0 data address pointer low byte page 84 dma0idt 0xde 3 dma0 instru ction write data page 82 dma0ipt 0xdd 3 dma0 instru ction write address page 82 dma0isw 0xfe 3 dma0 inst ruction status page 83 dph 0x83 all pages data pointer high page 148 dpl 0x82 all pages data pointer low page 148 eie1 0xe6 all pages extended interrupt enable 1 page 156 eie2 0xe7 all pages extended interrupt enable 2 page 157 eip1 0xf6 all pages extended interrupt priority 1 page 158 eip2 0xf7 all pages extended interrupt priority 2 page 159 emi0cf 0xa3 0 emif configuration page 189 *1 emi0cn 0xa2 0 emif control page 189 *1 emi0tc 0xa1 0 emif timing control page 194 *1 flacl 0xb7 f flash access limit page 182 flscl 0xb7 0 flash scale page 184 ie 0xa8 all pages interrupt enable page 154 ip 0xb8 all pages interrupt priority page 155 oscicl 0x8b f internal oscillator calibration page 172 oscicn 0x8a f internal os cillator control page 172 oscxcn 0x8c f external o scillator control page 174 p0 0x80 all pages port 0 latch page 214 p0mdout 0xa4 f port 0 output mode configuration page 214 p1 0x90 all pages port 1 latch page 215 p1mdin 0xad f port 1 input mode page 215 p1mdout 0xa5 f port 1 output mode configuration page 216 p2 0xa0 all pages port 2 latch page 216 table 13.3. special function registers (continued) sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 145 p2mdin 0xae f port 2 input mode page 217 p2mdout 0xa6 f port 2 output mode configuration page 217 p3 0xb0 all pages port 3 latch page 218 *1 p3mdout 0xa7 f port 3 output mode configuration page 218 *1 p4 0xc8 f port 4 latch page 221 *1 p4mdout 0x9c f port 4 output mode configuration page 221 *1 p5 0xd8 f port 5 latch page 222 *1 p5mdout 0x9d f port 5 output mode configuration page 222 *1 p6 0xe8 f port 6 latch page 223 *1 p6mdout 0x9e f port 6 output mode configuration page 223 *1 p7 0xf8 f port 7 latch page 224 *1 p7mdout 0x9f f port 7 output mode configuration page 224 *1 pca0cn 0xd8 0 pca control page 312 pca0cph0 0xfc 0 pca capture 0 high page 316 pca0cph1 0xfe 0 pca capture 1 high page 316 pca0cph2 0xea 0 pca capture 2 high page 316 pca0cph3 0xec 0 pca capture 3 high page 316 pca0cph4 0xee 0 pca capture 4 high page 316 pca0cph5 0xe2 0 pca capture 5 high page 316 pca0cpl0 0xfb 0 pca capture 0 low page 316 pca0cpl1 0xfd 0 pca capture 1 low page 316 pca0cpl2 0xe9 0 pca capture 2 low page 316 pca0cpl3 0xeb 0 pca capture 3 low page 316 pca0cpl4 0xed 0 pca capture 4 low page 316 pca0cpl5 0xe1 0 pca capture 5 low page 316 pca0cpm0 0xda 0 pca module 0 mode register page 314 pca0cpm1 0xdb 0 pca module 1 mode register page 314 pca0cpm2 0xdc 0 pca module 2 mode register page 314 pca0cpm3 0xdd 0 pca module 3 mode register page 314 pca0cpm4 0xde 0 pca module 4 mode register page 314 pca0cpm5 0xdf 0 pca module 5 mode register page 314 pca0h 0xfa 0 pca counter high page 315 pca0l 0xf9 0 pca counter low page 315 pca0md 0xd9 0 pca mode page 313 pcon 0x87 all pages power control page 161 psctl 0x8f 0 program store r/w control page 185 psw 0xd0 all pages program status word page 149 rcap2h 0xcb 0 timer/counter 2 capture/reload high page 301 rcap2l 0xca 0 timer/counter 2 capture/reload low page 301 rcap3h 0xcb 1 timer/counter 3 capture/reload high page 301 rcap3l 0xca 1 timer/counter 3 capture/reload low page 301 rcap4h 0xcb 2 timer/counter 4 capture/reload high page 301 rcap4l 0xca 2 timer/counter 4 capture/reload low page 301 table 13.3. special function registers (continued) sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no.
c8051f060/1/2/3/4/5/6/7 146 rev. 1.2 ref0cn 0xd1 0 voltage reference control 0 page 62 ref1cn 0xd1 1 voltage reference control 1 page 62 ref2cn 0xd1 2 voltage reference control 2 page 112 *2 , page 114 *3 , page 116 *5 rstsrc 0xef 0 reset source page 168 saddr0 0xa9 0 uart 0 slave address page 276 saden0 0xb9 0 uart 0 slave address enable page 276 sbuf0 0x99 0 uart 0 data buffer page 276 sbuf1 0x99 1 uart 1 data buffer page 283 scon0 0x98 0 uart 0 control page 274 scon1 0x98 1 uart 1 control page 282 sfrlast 0x86 all pages sfr page stack access register page 140 sfrnext 0x85 all pages sfr page register page 140 sfrpage 0x84 all pages sfr page register page 139 sfrpgcn 0x96 f sfr page control register page 139 smb0adr 0xc3 0 smbus slave address page 246 smb0cn 0xc0 0 smbus control page 243 smb0cr 0xcf 0 smbus clock rate page 244 smb0dat 0xc2 0 smbus data page 245 smb0sta 0xc1 0 smbus status page 247 sp 0x81 all pages stack pointer page 148 spi0cfg 0x9a 0 spi configuration page 258 spi0ckr 0x9d 0 spi clock rate control page 260 spi0cn 0xf8 0 spi control page 259 spi0dat 0x9b 0 spi data page 261 ssta0 0x91 0 uart 0 status page 275 tcon 0x88 0 timer/counter control page 291 th0 0x8c 0 timer/counter 0 high page 294 th1 0x8d 0 timer/counter 1 high page 294 tl0 0x8a 0 timer/counter 0 low page 294 tl1 0x8b 0 timer/counter 1 low page 294 tmod 0x89 0 timer/counter mode page 292 tmr2cf 0xc9 0 timer/counter 2 configuration page 300 tmr2cn 0xc8 0 timer/counter 2 control page 299 tmr2h 0xcd 0 timer/counter 2 high page 302 tmr2l 0xcc 0 timer/counter 2 low page 301 tmr3cf 0xc9 1 timer/counter 3 configuration page 300 tmr3cn 0xc8 1 timer/counter 3 control page 299 tmr3h 0xcd 1 timer/counter 3 high page 302 tmr3l 0xcc 1 timer/counter 3 low page 301 tmr4cf 0xc9 2 timer/counter 4 configuration page 300 tmr4cn 0xc8 2 timer/counter 4 control page 299 tmr4h 0xcd 2 timer/counter 4 high page 302 table 13.3. special function registers (continued) sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 147 tmr4l 0xcc 2 timer/counter 4 low page 301 wdtcn 0xff all pages watchdog timer control page 167 xbr0 0xe1 f port i/o crossbar control 0 page 210 xbr1 0xe2 f port i/o crossbar control 1 page 211 xbr2 0xe3 f port i/o crossbar control 2 page 212 xbr3 0xe4 f port i/o crossbar control 3 page 213 *1 refers to a register in the c8051f060/2/4/6 only. *2 refers to a register in the c8051f060/2 only. *3 refers to a register in the c8051f061/3 only. *4 refers to a register in the c8051f060/1/2/3 only. *5 refers to a register in the c8051f064/5/6/7 only. table 13.3. special function registers (continued) sfrs are listed in alphabetical order. all undefined sfr locations are reserved. register address sfr page description page no.
c8051f060/1/2/3/4/5/6/7 148 rev. 1.2 13.2.7. register descriptions following are descriptions of sfrs related to the opera tion of the cip-51 system controller. reserved bits should not be set to logic l. future product versions may use these bits to implement new features in which case the reset value of the bit will be logic 0, selectin g the feature's default stat e. detailed descriptions of the remaining sfrs are included in the sections of the datasheet associated with their corresponding sys- tem function. figure 13.13. sp: stack pointer bits7-0: sp: stack pointer. the stack pointer holds the location of the top of the stack. the stack pointer is incremented before every push operation. the sp r egister defaults to 0x07 after reset. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x81 all pages fi gure 13 . 14 . dpl : d a t a p o i n t er l ow b y t e bits7-0: dpl: data pointer low. the dpl register is the low byte of the 16-b it dptr. dptr is used to access indirectly addressed xram and flash memory. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x82 all pages figure 13.15. dph: data pointer high byte bits7-0: dph: data pointer high. the dph register is the high byte of the 16-b it dptr. dptr is used to access indirectly addressed xram and flash memory. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x83 all pages
c8051f060/1/2/3/4/5/6/7 rev. 1.2 149 figure 13.16. psw: program status word bit7: cy: carry flag. this bit is set when the last arithmetic operat ion resulted in a carry (addition) or a borrow (subtraction). it is cleared to 0 by all other arithmetic operations. bit6: ac: auxiliary carry flag. this bit is set when the last arithmetic operation resulted in a carry into (addition) or a bor- row from (subtraction) the high order nibble. it is cleared to 0 by all other arithmetic opera- tions. bit5: f0: user flag 0. this is a bit-addressable, general purpose flag for use under software control. bits4-3: rs1-rs0: register bank select. these bits select which register ban k is used during register accesses. bit2: ov: overflow flag. this bit is set to 1 under the following circumstances: ? an add, addc, or subb instructi on causes a sign-change overflow. ? a mul instruction results in an overflow (result is greater than 255). ? a div instruction causes a divide-by-zero condition. the ov bit is cleared to 0 by the add, addc, subb, mul, and div inst ructions in all other cases. bit1: f1: user flag 1. this is a bit-addressable, general purpose flag for use under software control. bit0: parity: parity flag. this bit is set to 1 if the sum of the eight bits in the accumulator is odd and cleared if the sum is even. r/w r/w r/w r/w r/w r/w r/w r/w reset value cy ac f0 rs1 rs0 ov f1 parity 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xd0 all pages rs1 rs0 register bank address 0 0 0 0x00 - 0x07 0 1 1 0x08 - 0x0f 1 0 2 0x10 - 0x17 1 1 3 0x18 - 0x1f
c8051f060/1/2/3/4/5/6/7 150 rev. 1.2 figure 13.17. acc: accumulator bits7-0: acc: accumulator. this register is the accumulator for arithmetic operations. r/w r/w r/w r/w r/w r/w r/w r/w reset value acc.7 acc.6 acc.5 acc.4 acc .3 acc.2 acc.1 acc.0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xe0 all pages figure 13.18. b: b register bits7-0: b: b register. this register serves as a second accumu lator for certain arithmetic operations. r/w r/w r/w r/w r/w r/w r/w r/w reset value b.7 b.6 b.5 b.4 b.3 b.2 b.1 b.0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xf0 all pages
c8051f060/1/2/3/4/5/6/7 rev. 1.2 151 13.3. interrupt handler the cip-51 includes an extended interrupt system supp orting a total of 22 interrupt sources with two prior- ity levels. the allocation of interrupt sources between on-chip peri pherals and external inputs pins varies according to the specific version of the device. each interrupt source has one or more associated interrupt- pending flag(s) located in an sfr. when a peripheral or external source meets a valid interrupt condition, the associated interrupt-pend ing flag is set to logic 1. if interrupts are enabled for the source, an interrupt re quest is generated when the interrupt-pending flag is set. as soon as execution of the current instructio n is complete, the cpu generates an lcall to a prede- termined address to begin execution of an interrupt service routine (isr). each isr must end with an reti instruction, which returns program execution to the next instruction that would have been executed if the interrupt request had not occurred. if interrupts are not enabled, the interrupt-pending flag is ignored by the hardware and program execution continues as normal. (t he interrupt-pending flag is set to logic 1 regard- less of the interrupt's enable/disable state.) each interrupt source can be individually enabled or disabled through the use of an associated interrupt enable bit in an sfr (ie-eie2). ho wever, interrupts must first be globally enabled by setting the ea bit (ie.7) to logic 1 before the individual interrupt enabl es are recognized. setting the ea bit to logic 0 disables all interrupt sources regardless of the individual interrupt-enable settings. some interrupt-pending flags are automatically cleare d by the hardware when the cpu vectors to the isr. however, most are not cleared by the hardware and must be cleared by software before returning from the isr. if an interrupt-pending flag remains set after the cpu completes the return-from-interrupt (reti) instruction, a new interr upt request will be gen erated immediately and the cpu will re-enter the isr after the completion of th e next instruction. 13.3.1. mcu interrupt sources and vectors the mcus support 22 interrupt sources. software can simulate an interrupt event by setting any interrupt- pending flag to logic 1. if interrupts are enabled for the flag, an interrupt request will be generated and the cpu will vector to the isr address associated wit h the interrupt-pending flag. mcu interrupt sources, associated vector addresses, priority order and cont rol bits are summarized in table 13.4. refer to the datasheet section associated with a particular on-chip peripheral for information regarding valid interrupt conditions for the peripheral and the behavior of its interrupt-pending flag(s). 13.3.2. external interrupts the external interrupt sources (/int0 and /int1) are c onfigurable as active-low level-sensitive or active- low edge-sensitive inputs depending on the setting of bits it0 (tcon.0) and it1 (tcon.2). ie0 (tcon.1) and ie1 (tcon.3) serve as the interrupt-pending flag for the /int0 and /int1 external interrupts, respec- tively. if an /int0 or /int1 external interrupt is conf igured as edge-sensitive, the corresponding interrupt- pending flag is automatically clea red by the hardware when the cpu vectors to the isr. when configured as level sensitive, the inte rrupt-pending flag follows the state of the external interrupt's input pin. the exter- nal interrupt source must hold the input active until the interrupt request is recogniz ed. it must then deacti- vate the interrupt request before execution of the isr completes or another interr upt request will be generated.
c8051f060/1/2/3/4/5/6/7 152 rev. 1.2 table 13.4. interrupt summary interrupt source interrupt vector priority order pending flag bit addressable cleared by hw enable flag priority control reset 0x0000 top none n/a n/a always enabled always highest external interrupt 0 (/int0) 0x0003 0 ie0 (tcon.1) y y ex0 (ie.0) px0 (ip.0) timer 0 overflow 0x000b 1 tf0 (tcon.5) y y et0 (ie.1) pt0 (ip.1) external interrupt 1 (/int1) 0x0013 2 ie1 (tcon.3) y y ex1 (ie.2) px1 (ip.2) timer 1 overflow 0x001b 3 tf1 (tcon.7) y y et1 (ie.3) pt1 (ip.3) uart0 0x0023 4 ri0 (scon0.0) ti0 (scon0.1) y es0 (ie.4) ps0 (ip.4) timer 2 0x002b 5 tf2 (tmr2cn.7) y et2 (ie.5) pt2 (ip.5) serial peripheral interface 0x0033 6 spif (spi0cn.7) wcol (spi0cn.6) modf (spi0cn.5) rxovrn (spi0cn.4) y espi0 (eie1.0) pspi0 (eip1.0) smbus interface 0x003b 7 si (smb0cn.3) y esmb0 (eie1.1) psmb0 (eip1.1) adc0 window comparator 0x0043 8 ad0wint (adc0cn.1) y ewadc0 (eie1.2) pwadc0 (eip1.2) programmable counter array 0x004b 9 cf (pca0cn.7) ccfn (pca0cn.n) y epca0 (eie1.3) ppca0 (eip1.3) comparator 0 0x0053 10 cp0fif/cp0rif (cpt0cn.4/.5) y cp0ie (eie1.4) pcp0 (eip1.4) comparator 1 0x005b 11 cp1fif/cp1rif (cpt1cn.4/.5) y cp1ie (eie1.5) pcp1 (eip1.5) comparator 2 0x0063 12 cp2fif/cp2rif (cpt2cn.4/.5) y cp2ie (eie1.6) pcp2 (eip1.6) adc0 end of conversion 0x006b 13 adc0int (adc0cn.5) y eadc0 (eie1.7) padc0 (eip1.7) timer 3 0x0073 14 tf3 (tmr3cn.7) y et3 (eie2.0) pt3 (eip2.0) adc1 end of conversion 0x007b 15 adc1int (adc1cn.5) y eadc1 (eie2.1) padc1 (eip2.1) timer 4 0x0083 16 tf4 (tmr4cn.7) y et4 (eie2.2) pt4 (eip2.2) adc2 window comparator 0x008b 17 ad2wint (adc2cn.1) y ewadc2 (eie2.3) pwadc2 (eip2.3) adc2 end of conversion 0x0093 18 ad2int (adc2cn.5) y eadc2 (eie2.4) padc2 (eip2.4) can interrupt 0x009b 19 can0cn.7 y y ecan0 (eie2.5) pcan0 (eip2.5) uart1 0x00a3 20 ri1 (scon1.0) ti1 (scon1.1) y es1 (eip2.6) ps1 (eip2.6) dma0 interrupt 0x00ab 21 dma0int (dma0cn.6) y edma0 (eie2.7) pdma0 (eip2.7)
c8051f060/1/2/3/4/5/6/7 rev. 1.2 153 13.3.3. interrupt priorities each interrupt source can be individually programmed to one of two priority levels: low or high. a low prior- ity interrupt service routine can be pr eempted by a high priority interrupt. a high priority interrupt cannot be preempted. each interrupt has an associated interrupt priority bit in an sfr (ip-eip2) used to configure its priority level. low priority is the default. if two interrupts are recognized simultaneously, the interrupt with the higher priority is serviced first. if both interrupts have the same priority level, a fixed priority order is used to arbitrate, given in table 13.4. 13.3.4. interrupt latency interrupt response time depends on the state of the cpu when the interrupt occurs. pending interrupts are sampled and priority decoded each system clock cycle. therefore, the fastest possible response time is 5 system clock cycles: 1 clock cycle to detect the interr upt and 4 clock cycles to complete the lcall to the isr. if an interrupt is pending when a reti is execut ed, a single instruction is executed before an lcall is made to service the pending interrupt. therefore, the maximum response time for an interrupt (when no other interrupt is currently being serviced or the new interrupt is of greater priority) occurs when the cpu is performing an reti instruct ion followed by a div as the next instructio n. in this case, th e response time is 18 system clock cycles: 1 clock cycle to detect the in terrupt, 5 clock cycles to execute the reti, 8 clock cycles to complete the div instruction and 4 clock cycl es to execute the lcall to the isr. if the cpu is executing an isr for an interr upt with equal or higher pr iority, the new interrupt will not be serviced until the current isr completes, including the reti and following instruction.
c8051f060/1/2/3/4/5/6/7 154 rev. 1.2 13.3.5. interrupt register descriptions the sfrs used to enable the interrupt sources and set t heir priority level are described below. refer to the datasheet section associated with a particular on-chip peripheral for information regarding valid interrupt conditions for the peripheral and the behavior of its interrupt-pending flag(s). figure 13.19. ie: interrupt enable bit7: ea: enable all interrupts. this bit globally enables/disables all interrupts. it overrides the individual interrupt mask set- tings. 0: disable all interrupt sources. 1: enable each interrupt accord ing to its individual mask setting. bit6: iegf0: general purpose flag 0. this is a general purpose flag for use under software control. bit5: et2: enabler timer 2 interrupt. this bit sets the masking of the timer 2 interrupt. 0: disable timer 2 interrupt. 1: enable interrupt requests generated by the tf2 flag. bit4: es0: enable uart0 interrupt. this bit sets the masking of the uart0 interrupt. 0: disable uart0 interrupt. 1: enable ua rt0 interrupt. bit3: et1: enable timer 1 interrupt. this bit sets the masking of the timer 1 interrupt. 0: disable all ti mer 1 interrupt. 1: enable interrupt requests generated by the tf1 flag. bit2: ex1: enable exte rnal interrupt 1. this bit sets the masking of external interrupt 1. 0: disable external interrupt 1. 1: enable interrupt requests generated by the /int1 pin. bit1: et0: enable timer 0 interrupt. this bit sets the masking of the timer 0 interrupt. 0: disable all ti mer 0 interrupt. 1: enable interrupt requests generated by the tf0 flag. bit0: ex0: enable exte rnal interrupt 0. this bit sets the masking of external interrupt 0. 0: disable external interrupt 0. 1: enable interrupt requests generated by the /int0 pin. r/w r/w r/w r/w r/w r/w r/w r/w reset value ea iegf0 et2 es0 et1 ex1 et0 ex0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xa8 all pages
c8051f060/1/2/3/4/5/6/7 rev. 1.2 155 figure 13.20. ip: interrupt priority bits7-6: unused. read = 11b, write = don't care. bit5: pt2: timer 2 interr upt priority control. this bit sets the priority of the timer 2 interrupt. 0: timer 2 interrupt set to low priority level. 1: timer 2 interrupt set to high priority level. bit4: ps0: uart0 interrupt priority control. this bit sets the priority of the uart0 interrupt. 0: uart0 interrupt set to low priority level. 1: uart0 interrupt set to high priority level. bit3: pt1: timer 1 interr upt priority control. this bit sets the priority of the timer 1 interrupt. 0: timer 1 interrupt set to low priority level. 1: timer 1 interrupt set to high priority level. bit2: px1: external interr upt 1 priority control. this bit sets the priority of the ex ternal interrupt 1 interrupt. 0: external interrupt 1 set to low priority level. 1: external interrupt 1 set to high priority level. bit1: pt0: timer 0 interr upt priority control. this bit sets the priority of the timer 0 interrupt. 0: timer 0 interrupt set to low priority level. 1: timer 0 interrupt set to high priority level. bit0: px0: external interr upt 0 priority control. this bit sets the priority of the ex ternal interrupt 0 interrupt. 0: external interrupt 0 set to low priority level. 1: external interrupt 0 set to high priority level. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - pt2 ps0 pt1 px1 pt0 px0 11000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xb8 all pages
c8051f060/1/2/3/4/5/6/7 156 rev. 1.2 figure 13.21. eie1: extended interrupt enable 1 bit7: eadc0: enable adc0 end of conversion interrupt. this bit sets the masking of the adc0 end of conversion interrupt. 0: disable adc0 co nversion interrupt. 1: enable interrupt requests generated by the adc1 conversion interrupt. bit6: cp2ie: enable comparator (cp2) interrupt. this bit sets the masking of the cp2 interrupt. 0: disable cp2 interrupts. 1: enable interrupt requests generated by the cp2if flag. bit6: cp1ie: enable comparator (cp1) interrupt. this bit sets the masking of the cp1 interrupt. 0: disable cp1 interrupts. 1: enable interrupt requests generated by the cp1if flag. bit6: cp0ie: enable comparator (cp0) interrupt. this bit sets the masking of the cp0 interrupt. 0: disable cp0 interrupts. 1: enable interrupt requests generated by the cp0if flag. bit3: epca0: enable programmable counter array (pca0) interrupt. this bit sets the masking of the pca0 interrupts. 0: disable all pc a0 interrupts. 1: enable interrupt requests generated by pca0. bit2: ewadc0: enable window comparison adc0 interrupt. this bit sets the masking of adc0 window comparison interrupt. 0: disable adc0 window comparison interrupt. 1: enable interrupt requests generated by adc0 window comparisons. bit1: esmb0: enable system management bus (smbus0) interrupt. this bit sets the masking of the smbus interrupt. 0: disable all smbus interrupts. 1: enable interrupt requests generated by the si flag. bit0: espi0: enable serial peripheral interfac e (spi0) in terrupt. this bit sets the masking of spi0 interrupt. 0: disable all spi0 interrupts. 1: enable interrupt requests generated by the spi0 flag. r/w r/w r/w r/w r/w r/w r/w r/w reset value eadc0 cp2ie cp1ie cp0ie epca0 ewadc0 esmb0 espi0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe6 all pages
c8051f060/1/2/3/4/5/6/7 rev. 1.2 157 figure 13.22. eie2: extended interrupt enable 2 bit7: edma0: enable dma0 interrupt. this bit sets the masking of the dma0 interrupt. 0: disable dma0 interrupt. 1: enable dm a0 interrupt. bit6: es1: enable uart1 interrupt. this bit sets the masking of the uart1 interrupt. 0: disable uart1 interrupt. 1: enable ua rt1 interrupt. bit5: ecan0: enable can controller interrupt. this bit sets the masking of the can controller interrupt. 0: disable can co ntroller interrupt. 1: enable interrupt requests generated by the can controller. bit4: eadc2: enable adc2 e nd of conversion interrupt. this bit sets the masking of the adc2 end of conversion interrupt. 0: disable adc2 end of conversion interrupt. 1: enable interrupt requests generated by the adc2 end of conversion interrupt. bit3: ewadc2: enable window comparison adc1 interrupt. this bit sets the masking of adc2 window comparison interrupt. 0: disable adc2 window comparison interrupt. 1: enable interrupt requests generated by adc2 window comparisons. bit2: et4: enable timer 4 interrupt this bit sets the masking of the timer 4 interrupt. 0: disable timer 4 interrupt. 1: enable interrupt requests generated by the tf4 flag. bit1: eadc1: enable adc1 end of conversion interrupt. this bit sets the masking of the adc1 end of conversion interrupt. 0: disable adc1 co nversion interrupt. 1: enable interrupt requests generated by the adc1 conversion interrupt. bit0: et3: enable timer 3 interrupt. this bit sets the masking of the timer 3 interrupt. 0: disable all ti mer 3 interrupts. 1: enable interrupt requests generated by the tf3 flag. r/w r/w r/w r/w r/w r/w r/w r/w reset value edma0 es1 ecan0 eadc2 ewadc2 et4 eadc1 et3 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe7 all pages
c8051f060/1/2/3/4/5/6/7 158 rev. 1.2 figure 13.23. eip1: extended interrupt priority 1 bit7: padc0: adc end of conversion interrupt priority control. this bit sets the priority of the adc0 end of conversion interrupt. 0: adc0 end of conversion inte rrupt set to low priority level. 1: adc0 end of conversion interrupt set to high priority level. bit6: pcp2: comparator2 (cp2) interrupt prio rity control. this bit sets the priority of the cp2 interrupt. 0: cp2 interrupt set to low priority level. 1: cp2 interrupt set to high priority level. bit5: pcp1: comparator1 (cp1) interrupt prio rity control. this bit sets the priority of the cp1 interrupt. 0: cp1 interrupt set to low priority level. 1: cp1 interrupt set to high priority level. bit4: pcp0: comparator0 (cp0) interrupt prio rity control. this bit sets the priority of the cp0 interrupt. 0: cp0 interrupt set to low priority level. 1: cp0 interrupt set to high priority level. bit3: ppca0: programmable counter arra y (pca0) interrupt priority control. this bit sets the priority of the pca0 interrupt. 0: pca0 interrupt set to low priority level. 1: pca0 interrupt set to high priority level. bit2: pwadc0: adc0 window comparator interrupt priority control. this bit sets the priority of the adc0 window interrupt. 0: adc0 window interrupt set to low priority level. 1: adc0 window interrupt se t to high priority level. bit1: psmb0: system management bus (s mbus0) interrupt priority control. this bit sets the priority of the smbu s0 interrupt. 0: smbus interr upt set to low priority level. 1: smbus interrup t set to high priority level. bit0: pspi0: serial periph eral interface (spi0) in terrupt priority control. this bit sets the priority of the spi0 interrupt. 0: spi0 interrupt set to low priority level. 1: spi0 interrupt set to high priority level. r/w r/w r/w r/w r/w r/w r/w r/w reset value padc0 pcp2 pcp1 pcp0 ppca0 pwadc0 psmb0 pspi0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xf6 all pages
c8051f060/1/2/3/4/5/6/7 rev. 1.2 159 figure 13.24. eip2: extended interrupt priority 2 bit7: pdma0: dma0 interr upt priority control. this bit sets the priority of the dma0 interrupt. 0: dma0 interrupt se t to low priority. 1: dma0 interrupt se t to high priority. bit6: ps1: uart1 interrupt priority control. this bit sets the priority of the uart1 interrupt. 0: uart1 interrupt se t to low priority. 1: uart1 interrupt se t to high priority. bit5: pcan0: can interrup t priority control. this bit sets the priority of the can interrupt. 0: can interrupt set to low priority level. 1: can interrupt set to high priority level. bit4: padc2: adc2 end of conversion interr upt priority control. this bit sets the priority of the adc2 end of conversion interrupt. 0: adc2 end of conversion in terrupt set to low priority. 1: adc2 end of conversion interrupt set to high priority. bit3: pwadc2: adc2 window comparator interrupt priority control. 0: adc2 window interrup t set to low priority. 1: adc2 window interrup t set to high priority. bit2: pt4: timer 4 interrupt priority control. this bit sets the priority of the timer 4 interrupt. 0: timer 4 interrupt set to low priority. 1: timer 4 interrupt set to high priority. bit1: padc1: adc end of conversion interrupt priority control. this bit sets the priority of the adc1 end of conversion interrupt. 0: adc1 end of conversion inte rrupt set to low priority level. 1: adc1 end of conversion interrupt set to high priority level. bit0: pt3: timer 3 interr upt priority control. this bit sets the priority of the timer 3 interrupts. 0: timer 3 interrupt set to low priority level. 1: timer 3 interrupt set to high priority level. r/w r/w r/w r/w r/w r/w r/w r/w reset value pdma0 ps1 pcan0 padc2 pwadc2 pt4 padc1 pt3 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xf7 all pages
c8051f060/1/2/3/4/5/6/7 160 rev. 1.2 13.4. power management modes the cip-51 core has two software programmable power management modes: idle and stop. idle mode halts the cpu while leaving the external peripherals and internal clocks active. in stop mode, the cpu is halted, all interrupts and timers (e xcept the missing clock detector) are in active, and the internal oscillator is stopped. since clocks are running in idle mode, power consumption is dependent upon the system clock frequency and the number of peripherals left in active mode before entering idle. stop mode consumes the least power. figure 13.25 describes the power contro l register (pcon) used to control the cip-51's power management modes. although the cip-51 has idle and stop modes built in (as with any standard 8051 architecture), power management of the entire mcu is better accomplished by enabling/disabling individual peripherals as needed. each analog peripheral can be disabled when not in use and put into low power mode. digital peripherals, such as timers or serial buses, draw littl e power whenever they are not in use. turning off the oscillator saves even more power, but requires a reset to restart the mcu. 13.4.1. idle mode setting the idle mode select bit (pcon.0) causes the cip-51 to halt the cpu and enter idle mode as soon as the instruction that sets the bit completes. all internal register s and memory maintain their original data. all analog and digital peripherals can remain active during idle mode. idle mode is terminated when an enabled interrupt or /rst is asserted. the assertion of an enabled inter- rupt will cause the idle m ode selection bit (pcon.0) to be cleared and the cpu to resume operation. the pending interrupt will be serviced and the next instru ction to be executed after the return from interrupt (reti) will be the instruction immediat ely following the one that set the idle mode select bit. if idle mode is terminated by an internal or external reset, the cip-51 performs a normal reset sequence and begins pro- gram execution at address 0x0000. if enabled, the wdt will eventually cause an internal watchdog reset and thereby terminate the idle mode. this feature protects the system from an unintended permanent shutdown in the event of an inadvertent write to the pcon register. if this behavior is not desired, the wdt ma y be disabled by software prior to entering the idle mode if the wdt was initially configured to allow this operation. this provides the oppor- tunity for additional power savings, allowing the system to remain in the idle mo de indefinitely, waiting for an external stimulus to wake up the system. refer to section 14.7 for more information on the use and configuration of the wdt. note: any instruction which sets the idle bit should be immediately followed by an instruction which has two or more opcode bytes.for example: // in ?c?: pcon |= 0x01; // set idle bit pcon = pcon; // ... followed by a 3-cycle dummy instruction ; in assembly: orl pcon, #01h ; set idle bit mov pcon, pcon ; ... followed by a 3-cycle dummy instruction if the instruction following the write to the idle bit is a single-byte in struction and an interrupt occurs during the execution of the instruction of the instruction which sets the idle bit, the cpu may not wake from idle mode when a future interrupt occurs.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 161 13.4.2. stop mode setting the stop mode select bit (pcon.1) causes the ci p-51 to enter stop mode as soon as the instruc- tion that sets the bit completes. in stop mode, the cpu and internal oscillators are stopped, effectively shutting down all digital peripherals. each analog peri pheral must be shut down individually prior to enter- ing stop mode. stop mode can only be terminated by an internal or external rese t. on reset, the cip-51 performs the normal reset sequence and begi ns program execution at address 0x0000. if enabled, the missing clock detect or will cause an internal reset and ther eby terminate th e stop mode. the missing clock detector should be disabled if the cpu is to be put to sleep for longer than the mcd timeout of 100 s. figure 13.25. pcon: power control bits7-2: reserved. bit1: stop: stop mode select. writing a ?1? to this bit will place the cip-51 into stop mode. this bit will always read ?0?. 1: cip-51 forced into po wer-down mode. (turns of f internal oscillator). bit0: idle: idle mode select. writing a ?1? to this bit will place the cip-51 into idle mode. this bit will always read ?0?. 1: cip-51 forced into idle mode. (shuts off cl ock to cpu, but clock to timers, interrupts, and all peripherals remain active.) see note in section ? 13.4.1. idle mode ? on page 160 . r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - - - stop idle 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x87 all pages
c8051f060/1/2/3/4/5/6/7 162 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 163 14. reset sources reset circuitry allows the controller to be easily placed in a predefined default condition. on entry to this reset state, th e following occur: ? cip-51 halts program execution ? special function registers (sfrs) are initialized to their defined reset values ? external port pins are forced to a known configuration ? interrupts and timers are disabled. all sfrs are reset to the predefined values noted in the sfr detailed descriptions. the contents of internal data memory are unaffected during a reset; any prev iously stored data is preserved. however, since the stack pointer sfr is reset, the stack is effectively lo st even though the data on the stack are not altered. the i/o port latches are reset to 0xff (all logic 1?s), activating internal weak pu ll-ups which take the exter- nal i/o pins to a high state. the external i/o pins do not go high immediately, but will go high within four system clock cycles after entering the re set state. this allows power to be conserved while the part is held in reset. for vdd monitor resets, the /rst pin is driven low until the end of the vdd reset timeout. on exit from the reset state, the program counter (pc) is reset, and the system clock defaults to the inter- nal oscillator runn ing at its lowest freque ncy. refer to section ? 15. oscillators ? on page 171 for information on selecting and configuring the system clock source . the watchdog timer is enabled using its longest timeout interval (see section ? 14.7. watchdog timer reset ? on page 165 ). once the system clock source is stable, program execution begins at location 0x0000. there are seven sources for putting the mcu into the reset state: power-on, power-fail, external /rst pin, external cnvstr2 signal, softwa re command, comparator0, missing clock detector, and watchdog timer. each reset source is de scribed in the following sections. wdt xtal1 xtal2 osc internal clock generator system clock cip-51 microcontroller core missing clock detector (one- shot) wdt strobe software reset extended interrupt handler clock select /rst + - vdd supply reset timeout (wired-or) system reset supply monitor pre reset funnel + - cp0+ comparator0 cp0- (port i/o) crossbar cnvstr2 (cnvstr reset enable) (cp0 reset enable) en wdt enable en mcd enable (wired-or) vdd monitor reset enable figure 14.1. reset sources
c8051f060/1/2/3/4/5/6/7 164 rev. 1.2 14.1. power-on reset the c8051f060/1/2/3/4/5/6/7 family incorporates a po wer supply monitor that holds the mcu in the reset state until vdd rises above the v rst level during power-up. see figure 14.2 for timing diagram, and refer to table 14.1 for the electrical characteristics of the power supply monitor circuit. the /rst pin is asserted low until the end of the 100 ms vdd mo nitor timeout in order to allow th e vdd supply to stabilize. the vdd monitor reset is enabled and disabled using the external vdd monitor enable pin (monen). on exit from a power-on reset, the porsf flag (rstsr c.1) is set by hardware to logic 1. all of the other reset flags in the rstsrc register are indeterminat e. porsf is cleared by all other resets. since all resets cause program execution to begin at the same location (0x0000) software can read the porsf flag to determine if a power-up was the cause of reset. the contents of internal data memory should be assumed to be undefined after a power-on reset. 14.2. power-fail reset when a power-down transition or power irregularity causes vdd to drop below v rst , the power supply monitor will drive the /rst pin low and return the cip-51 to the reset state. when vdd returns to a level above vrst, the cip-51 will leave the reset state in th e same manner as that for the power-on reset (see figure 14.2). note that even though internal data me mory contents are not altered by the power-fail reset, it is impossible to determine if v dd dropped below the level required fo r data retention. if the porsf flag is set to logic 1, the data may no longer be valid. 14.3. external reset the external /rst pin provides a means for external ci rcuitry to force the mcu into a reset state. asserting the /rst pin low will cause the mcu to enter the reset state. it may be desirable to provide an external pull-up and/or decoupling of the /rst pin to avoid erroneous noise-in duced resets. the mcu will remain in vdd monitor reset power-on reset /rst t volts 1.0 2.0 logic high logic low 100ms 100ms v d d 2.70 2.55 v rst figure 14.2. reset timing
c8051f060/1/2/3/4/5/6/7 rev. 1.2 165 reset until at least 12 clock cycles after the acti ve-low /rst signal is removed. the pinrsf flag (rstsrc.0) is set on exit from an external reset. 14.4. missing clock detector reset the missing clock detector is essentia lly a one-shot circuit that is trig gered by the mcu system clock. if the system clock goes away for more than 100 s, the one-shot will time out and generate a reset. after a missing clock detector re set, the mcdrsf flag (rstsrc.2) will be set, signifying the msd as the reset source; otherwise, this bit reads ?0?. the state of t he /rst pin is unaffected by this reset. setting the mcdrsf bit, rstsrc.2 (see section ? 15. oscillators ? on page 171 ) enables the missing clock detector. 14.5. comparator0 reset comparator0 can be configured as a reset input by writing a ?1? to the c0rsef flag (rstsrc.5). comparator0 should be enabled using cpt0cn.7 (see section ? 12. comparators ? on page 117 ) prior to writing to c0rsef to prevent any turn-on chatter on the output from generating an unwanted reset. the comparator0 reset is active-low: if the non-invertin g input voltage (cp0+ pin) is less than the inverting input voltage (cp0- pin), the mcu is put into the rese t state. after a comparator0 reset, the c0rsef flag (rstsrc.5) will read ?1? signifying comp arator0 as the reset sour ce; otherwise, this bit reads ?0?. the state of the /rst pin is unaffected by this reset. 14.6. external cnvstr2 pin reset the external cnvstr2 signal can be configured as a reset input by writing a ?1? to the cnvrsef flag (rstsrc.6). the cnvstr2 signal can appear on any of the p0, p1, p2 or p3 i/o pins as described in section ? 18.1. ports 0 through 3 and the priority crossbar decoder ? on page 205 . note that the crossbar must be configured for the cnvstr2 signal to be routed to the appropriate port i/o. the crossbar should be configured and enabled before the cnvrsef is set. cnvstr2 cannot be used to start adc2 conver- sions when it is configured as a reset source. when configured as a reset, cnvstr2 is active-low and level sensitive. after a cnvstr2 reset, the cnvrsef flag (rstsrc.6) will read ?1? signifying cnvstr2 as the reset source; otherwise, this bit reads ?0?. th e state of the /rst pin is unaffected by this reset. 14.7. watchdog timer reset the mcu includes a program mable watchdog timer (wdt ) running off the system clock. a wdt overflow will force the mcu into the rese t state. to prevent the reset, the wdt mu st be restarted by application soft- ware before overflow. if the system experiences a soft ware or hardware malfuncti on preventing the soft- ware from restarting the wdt, the wdt will overfl ow and cause a reset. this should prevent the system from running out of control. following a reset the wdt is automatically enabled and running with the default maximum time interval. if desired the wdt can be disabled by system software or locked on to prevent accidental disabling. once locked, the wdt cannot be disabled until the next s ystem reset. the state of th e /rst pin is unaffected by this reset. the wdt consists of a 21-bit timer running from th e programmed system clock. the timer measures the period between specific writes to its control register. if this period exceeds the programmed limit, a wdt reset is generated. the wdt can be enabled and disabled as needed in software, or can be permanently enabled if desired. watchdog features are contro lled via the watchdog timer control register (wdtcn) shown in figure 14.3.
c8051f060/1/2/3/4/5/6/7 166 rev. 1.2 14.7.1. enable/reset wdt the watchdog timer is both enabled and reset by writ ing 0xa5 to the wdtcn register. the user's applica- tion software should include periodic writes of 0x a5 to wdtcn as needed to prevent a watchdog timer overflow. the wdt is enabled and rese t as a result of any system reset. 14.7.2. disable wdt writing 0xde followed by 0xad to the wdtcn regi ster disables the wdt. the following code segment illustrates disabling the wdt: clr ea ; disable all interrupts mov wdtcn,#0deh ; disable software watchdog timer mov wdtcn,#0adh setb ea ; re-enable interrupts the writes of 0xde and 0xad must occur within 4 clo ck cycles of each other, or the disable operation is ignored. interrupts should be disabled during this procedure to avoid delay between the two writes. 14.7.3. disable wdt lockout writing 0xff to wdtcn locks out the disable feature. once locked out, the disable operation is ignored until the next system reset. writing 0xff does not enabl e or reset the watchdog timer. applications always intending to use the watchdog should writ e 0xff to wdtcn in the initialization code. 14.7.4. setting wdt interval wdtcn.[2:0] control the watchdog timeout interval. the interval is given by the following equation: ; where t sysclk is the system clock period. 4 3 wdtcn 20 ? [] + t sysclk
c8051f060/1/2/3/4/5/6/7 rev. 1.2 167 for a 3 mhz system clock, this provides an interval range of 0.021 ms to 349.5 ms. wdtcn.7 must be logic 0 when setting this interval . reading wdtcn returns the progra mmed interval. wdtcn.[2:0] reads 111b after a system reset. bits7-0: wdt control. writing 0xa5 both enables and reloads the wdt. writing 0xde followed within 4 system clocks by 0xad disables the wdt. writing 0xff locks out the disable feature. bit4: watchdog status bit (when read). reading the wdtcn.[4] bit indicates the watchdog timer status. 0: wdt is inactive. 1: wdt is active. bits2-0: watchdog timeout interval bits. the wdtcn.[2:0] bits set the watchdog timeout interval. when writing these bits, wdtcn.7 must be set to 0. r/w r/w r/w r/w r/w r/w r/w r/w reset value xxxxx111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xff all pages figure 14.3. wdtcn: watchdog timer control register
c8051f060/1/2/3/4/5/6/7 168 rev. 1.2 figure 14.4. rstsrc: reset source register bit7: reserved. bit6: cnvrsef: convert start reset source enable and flag write: 0: cnvstr2 is not a reset source. 1: cnvstr2 is a reset source (active low). read: 0: source of prior reset was not cnvstr2. 1: source of prior reset was cnvstr2. bit5: c0rsef: comparator0 reset enable and flag. write: 0: comparator0 is not a reset source. 1: comparator0 is a reset source (active low). read: 0: source of last reset was not comparator0. 1: source of last reset was comparator0. bit4: swrsf: software reset force and flag. write: 0: no effect. 1: forces an internal reset. /rst pin is not effected. read: 0: source of last reset was not a write to the swrsf bit. 1: source of last reset was a write to the swrsf bit. bit3: wdtrsf: watchdog timer reset flag. 0: source of last reset was not wdt timeout. 1: source of last reset was wdt timeout. bit2: mcdrsf: missing clock detector flag. write: 0: missing clock detector disabled. 1: missing clock detector enabled; triggers a reset if a missing clock condition is detected. read: 0: source of last reset was not a missing clock detector timeout. 1: source of last reset was a missing clock detector timeout. bit1: porsf: power-on reset flag. write: if the vdd monitor circuitry is enabled (b y tying the monen pin to a logic high state), this bit can be written to select or de-select the vdd monitor as a reset source. 0: de-select the vdd monitor as a reset source. 1: select the vdd monitor as a reset source. important: at power-on, the vdd monitor is enabled/disabled using the external vdd monitor enable pin (monen). the porsf bit does not disable or enable the vdd monitor circuit. it simply selects the vdd monitor as a reset source. read: this bit is set whenever a power-on reset occurs. this may be due to a true power-on reset or a vdd monitor reset. in either case, data memory should be considered indeterminate following the reset. 0: source of last reset was not a power-on or vdd monitor reset. 1: source of last reset was a power-on or vdd monitor reset. note: when this flag is read as '1', all other reset flags are indeterminate. bit0: pinrsf: hw pin reset flag. write: 0: no effect. 1: forces a power-on reset. /rst is driven low. read: 0: source of prior reset was not /rst pin. 1: source of prior reset was /rst pin. r r/w r/w r/w r r/w r/w r/w reset value - cnvrsef c0rsef swrsef wdtrsf mcdrsf porsf pinrsf 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xef 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 169 table 14.1. reset electrical characteristics -40 to +85 c unless otherwise specified. parameter conditions min typ max units /rst output low voltage i ol = 8.5 ma, vdd = 2.7 v to 3.6 v 0.6 v /rst input high voltage 0.7 x vdd v /rst input low voltage 0.3 x vdd /rst input leakage current /rst = 0.0 v 50 a vdd for /rst output valid 1.0 v av+ for /rst output valid 1.0 v vdd por threshold (v rst ) 2.40 2.55 2.70 v minimum /rst low time to generate a system reset 10 ns reset time delay /rst rising edge after vdd crosses v rst threshold 80 100 120 ms missing clock detector time- out time from last system clock to reset initiation 100 220 500 s
c8051f060/1/2/3/4/5/6/7 170 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 171 15. oscillators c8051f060/1/2/3/4/5/6/7 de vices include a programmabl e internal oscillator and an external oscillator drive circuit. the intern al oscillator can be enabled, disabled and calibrated using the oscicn and oscicl registers, as shown in figur e 15.1. the system clock can be sour ced by the external oscillator cir- cuit, the internal oscillator, or a scaled version of the internal oscilla tor. the internal oscillator's electrical specifications are given in table 15.1. 15.1. programmable internal oscillator all c8051f060/1/2/3/4/5/6/7 devices include a programma ble internal oscillator t hat defaults as the system clock after a system reset. the internal oscillator pe riod can be adjusted via the oscicl register as defined by figure 15.2. oscicl is factory calib rated to obtain a 24.5 mhz base frequency ( f base ). electrical specifications for the pr ecision internal oscillator are given in table 15.1. th e programmed inter- nal oscillator frequency must not exceed 25 mhz. note that the syst em clock may be de rived from the pro- grammed internal oscillator divided by 1, 2, 4, or 8, as defined by the ifcn bits in register oscicn. figure 15.1. oscillator diagram osc programmable internal clock generator input circuit en sysclk n oscicl oscicn ioscen ifrdy ifcn1 ifcn0 xtal1 xtal2 option 2 vdd xtal1 option 1 option 4 xtal1 oscxcn xtlvld xoscmd2 xoscmd1 xoscmd0 xfcn2 xfcn1 xfcn0 clksel clksl 0 1 option 3 xtal1 xtal2
c8051f060/1/2/3/4/5/6/7 172 rev. 1.2 . figure 15.2. oscicl: internal oscillator calibration register bits 7-0: oscicl: internal os cillator calibration register this register calibrates the internal osc illator period. the reset value for oscicl defines the internal oscillator base frequency. the reset value is factory calibrated to generate an inter- nal oscillator frequency of 24.5 mhz. r/w r/w r/w r/w r/w r/w r/w r/w reset value variable bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8b f figure 15.3. oscicn: internal oscillator control register bit7: ioscen: internal oscillator enable bit 0: internal oscillator disabled 1: internal oscillator enabled bit6: ifrdy: internal osc illator frequency ready flag 0: internal oscillator not ru nning at programmed frequency. 1: internal oscillator runni ng at programmed frequency. bits5-2: reserved. bits1-0: ifcn1-0: internal osc illator frequency control bits 00: sysclk derived from intern al oscillator divided by 8. 01: sysclk derived from intern al oscillator divided by 4. 10: sysclk derived from intern al oscillator divided by 2. 11: sysclk derived from internal oscillator divided by 1. r/w r r/w r r/w r/w r/w r/w reset value ioscen ifrdy - - - - ifcn1 ifcn0 11000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8a f
c8051f060/1/2/3/4/5/6/7 rev. 1.2 173 15.2. external oscill ator drive circuit the external oscillator circuit may drive an external cr ystal, ceramic resona tor, capacitor, or rc network. a cmos clock may also provide a clock input. for a crys tal or ceramic resonator configuration, the crystal/ resonator must be wired across the xtal1 and xtal2 pins as shown in option 1 of figure 15.1. in rc, capacitor, or cmos clock configuration, the clock source should be wired to the xtal2 and/or xtal1 pin(s) as shown in option 2, 3, or 4 of figure 15.1. the type of external oscillator must be selected in the oscxcn register, and the frequency control bits (xfcn) must be selected appropriately (see figure 15.5). 15.3. system clock selection the clksl bit in register clksel selects which osc illator generates the system clock. clksl must be set to ?1? for the system clock to run from the external oscillator; ho wever the external oscillator may still clock peripherals (timers, pca) when the internal oscillator is select ed as the system clock. the system clock may be switched on -the-fly betwe en the internal and exter nal oscillator, so long as the selected oscil- lator is enabled and settled . the internal oscillator re quires little start-up time , and may be enabled and selected as the system clock in the same write to os cicn. external crystals an d ceramic resonators typi- cally require a start-up time before they are settle d and ready for use as the system clock. the crystal valid flag (xtlvld in register oscx cn) is set to ?1? by hardware when the external oscillator is settled. to avoid reading a false xtlvld, in crystal mode software should delay at least 1 ms between enabling the external oscillator and checking xtlvld. rc and c modes typically require no startup time. table 15.1. internal oscillator electrical characteristics -40c to +85c unles otherwise specified. parameter conditions min typ max units calibrated internal oscillator frequency 24 24.5 25 mhz internal oscillator supply current (3.0v supply) oscicn.7 = 1 550 a figure 15.4. clksel: oscillator clock selection register bits7-1: reserved. bit0: clksl: system clo ck source select bit. 0: sysclk derived from the inte rnal oscillator , and scaled as per the ifcn bits in oscicn. 1: sysclk derived from the external oscillator circuit. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - - - - clksl 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x97 f
c8051f060/1/2/3/4/5/6/7 174 rev. 1.2 figure 15.5. oscxcn: external oscillator control register bit7: xtlvld: crystal oscillator valid flag. ( valid only when xoscmd = 11x. ). 0: crystal oscillator is unused or not yet stable. 1: crystal oscillator is running and stable. bits6-4: xoscmd2-0: extern al oscillator mode bits. 00x: external osc illator circuit off. 010: external cmos clock mode (exter nal cmos clock input on xtal1 pin). 011: external cmos clock mode with divide by 2 stage (external cmos clock input on xtal1 pin). 10x: rc/c oscillator mode with divide by 2 stage. 110: crystal oscillator mode. 111: crystal oscillator mode with divide by 2 stage. bit3: unused. read = 0, write = don't care. bits2-0: xfcn2-0: external osc illator frequency control bits. 000-111: see table below: crystal mode (circuit from figure 15.1, option 1; xoscmd = 11x). choose xfcn value to match crystal frequency. rc mode (circuit from figure 15.1, option 2; xoscmd = 10x). choose xfcn value to match frequency range: f = 1.23(10 3 ) / (r * c) , where f = frequency of oscillation in mhz c = capacitor value in pf r = pull-up resist or value in k ? c mode (circuit from figure 15.1, option 3; xoscmd = 10x). choose k factor (kf) for the oscillation frequency desired: f = kf / (c * vdd) , where f = frequency of oscillation in mhz c = capacitor value on xtal1, xtal2 pins in pf vdd = power supply on mcu in volts r r/w r/w r/w r r/w r/w r/w reset value xtlvld xoscmd2 xoscmd1 xoscmd0 - xfcn2 xfcn1 xfcn0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8c f xfcn crystal (xoscmd = 11x) rc (xoscmd = 10x) c (xoscmd = 10x) 000 f 32 khz f 25 khz k factor = 0.87 001 32 khz < f 84 khz 25 khz < f 50 khz k factor = 2.6 010 84 khz < f 225 khz 50 khz < f 100 khz k factor = 7.7 011 225 khz < f 590khz 100khz < f 200 khz k factor = 22 100 590 khz < f 1.5 mhz 200 khz < f 400 khz k factor = 65 101 1.5 mhz < f 4mhz 400khz < f 800 khz k factor = 180 110 4 mhz < f 10 mhz 800 khz < f 1.6 mhz k factor = 664 111 10 mhz < f 30 mhz 1.6 mhz < f 3.2 mhz k factor = 1590
c8051f060/1/2/3/4/5/6/7 rev. 1.2 175 15.4. external crystal example if a crystal or ceramic resonator is us ed as an external osc illator source for the mcu, the circuit should be configured as shown in figure 15.1, option 1. the external oscillato r frequency cont rol value (xfcn) should be chosen from the crystal column of the ta ble in figure 15.5 (oscxcn register). for example, an 11.0592 mhz crystal requires an xfcn setting of 111b. when the crystal oscillator is enabl ed, the oscillator amplit ude detection circuit requires a settle time to achieve proper bias. introducing a bl anking interval of at least 1 ms between enabling the oscillator and checking the xtlvld bit will prevent a premature switch to the external oscillator as the system clock. switching to the external oscillato r before the crystal oscillator has st abilized can result in unpredictable behavior. the recommended procedure is: step 1. enable the external oscillator. step 2. wait at least1 ms. step 3. poll for xtlvld => ?1?. step 4. switch the system clo ck to the external oscillator. important note on external crystals: crystal oscillator circuits are qu ite sensitive to pcb layout and external noise. the crystal should be placed as clos e as possible to the xtal pins on the device. the traces should be as short as possible and shielded with ground plane from any other traces which could introduce noise or interference. crystal loadi ng capacitors should be referenced to agnd. 15.5. external rc example if an rc network is used as an external oscillator so urce for the mcu, the circ uit should be configured as shown in figure 15.1, option 2. the capacitor should be no greater than 100 pf; however for very small capacitors, the total capacitance may be dominated by parasitic capacitance in the pcb layout. to deter- mine the required external oscilla tor frequency control va lue (xfcn) in the oscxcn register, first select the rc network value to pr oduce the desired frequency of osc illation. if the frequency desired is 100 khz, let r = 246 k ? and c = 50 pf: f = 1.23( 10 3 ) / rc = 1.23 ( 10 3 )/[246*50] = 0.1mhz = 100khz referring to the table in figure 15.5, the required xfcn setting is 010. 15.6. external capacitor example if a capacitor is used as an external oscillator for t he mcu, the circuit should be configured as shown in figure 15.1, option 3. the capacitor should be no gr eater than 100 pf; however for very small capacitors, the total capacitance may be dominated by parasiti c capacitance in the pcb layout. to determine the required external oscillato r frequency control value (xfcn) in th e oscxcn register, select the capaci- tor to be used and find the frequency of oscillation fr om the equations below. assume vdd = 3.0 v and c = 50 pf: f = kf / ( c * vdd ) = kf / ( 50 * 3 ) f = kf / 150 if a frequency of roughly 50 khz is desired, select the k factor from the table in figure 15.5 as kf = 7.7: f = 7.7 / 150 = 0.051 mhz, or 51 khz therefore, the xfcn value to use in this example is 010.
c8051f060/1/2/3/4/5/6/7 176 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 177 16. flash memory the c8051f060/1/2/3/4/5/6/ 7 devices include on-chip, reprogrammable flash memory for program code and non-volatile data storage. the c8051f060/1/2/3/4/5 include 64 k + 128 bytes of flash, and the c8051f066/7 include 32 k + 128 bytes of flash. the flash memory can be programmed in-system, a sin- gle byte at a time, through the jtag interface or by software using the mo vx write instructions. once cleared to logic 0, a flash bit must be erased to set it back to logic 1. the bytes would typically be erased (set to 0xff) before being reprogrammed. flash wr ite and erase operations are automatically timed by hardware for proper execution; da ta polling to determine the end of the write/erase op eration is not required. the cpu is stalled during write/erase opera tions while the device peripherals remain active. interrupts that occur during flash write/erase operati ons are held, and are then serviced in their priority order once the flash operation has completed. refer to table 16.1 for the electric al characteristics of the flash memory. 16.1. programming the flash memory the simplest means of programming the flash memory is through the jtag interface using programming tools provided by silicon labs or a third party vendor. this is the only means for programming a non-initial- ized device. for details on the jtag co mmands to program flash memory, see section ?26. jtag (ieee 1149.1)? on page 317 . the flash memory can be programmed from software using the movx write instruction with the address and data byte to be programmed provided as norma l operands. before writing to flash memory using movx, flash write operations must be enabled by setting the pswe program store write enable bit (psctl.0) to logic 1. this direct s the movx writes to flash memory instead of to xram, which is the default target. the pswe bit remains set until cleared by software. to avoid errant flash writes, it is rec- ommended that interrupts be disabled while the pswe bit is logic 1. flash memory is read using the movc instruction. movx reads are always directed to xram, regardless of the state of pswe. note : to ensure the integrity of flash memory contents, it is strongly recommended that the on- chip vdd monitor be enabled by connecting the vdd monitor enable pin (monen) to vdd and set- ting the porsf bit in the rstsrc register to ?1? in any system that writes and/or erases flash memory from software. see ?reset s ources? on page 163 for more information. a write to flash memory can clear bits but cannot set them; only an erase operation can set bits in flash. a byte location to be programmed must be erased before a new value can be written . the flash memory is organized in 512-byte pages. the erase operat ion applies to an entire page (setting all bytes in the page to 0xff). the following steps illustrate the al gorithm for progra mming flash from user software. step 1. disable interrupts. step 2. set flwe (flscl.0) to enable fl ash writes/erases via user software. step 3. set psee (psctl.1) to enable flash erases. step 4. set pswe (psctl.0 ) to redirect movx commands to write to flash. step 5. use the movx command to write a data byte to any location within the 512-byte page to be erased. step 6. clear psee to disable flash erases step 7. use the movx command to write a data by te to the desired byte location within the erased 512-byte page. repeat this step until all desired bytes are written (within the target page).
c8051f060/1/2/3/4/5/6/7 178 rev. 1.2 step 8. clear the pswe bit to redirect movx write commands to the xram data space. step 9. re-enable interrupts. write/erase timing is automatically co ntrolled by hardware. note that code execution in the 8051 is stalled while the flash is being programmed or erased. 16.2. non-volatile data storage the flash memory can be used for non-volatile data storage as well as program code. this allows data such as calibration coefficients to be calculated and stored at run time. data is written using the movx write instruction (as described in the previous section) and read using the movc instruction. an additional 128-byte sector of flash memory is incl uded for non-volatile data storage. its smaller sector size makes it particularly well suited as general purpose, non-volatile scratchpad memory. even though flash memory can be written a single byte at a time , an entire sector must be erased first. in order to change a single byte of a multi-byte data set, the data must be moved to temporary storage. the 128-byte sector size facilitates updating da ta without wasting prog ram memory or ram spac e. the 128-byte sector is double-mapped over the normal flash memory ar ea; its address ranges from 0x00 to 0x7f (see figure 16.1 and figure 16.2). to access this 128-byte se ctor, the sfle bit in psctl must be set to logic 1. code execution from this 128-byte scratchpad sector is not supported. table 16.1. flash electrical characteristics parameter conditions min typ max units flash size * c8051f060/1/2/3/4/5 65664 ? bytes flash size * c8051f066/7 32896 bytes endurance 20 k 100 k erase/write erase cycle time 10 12 14 ms write cycle time 40 50 60 s * includes 128-byte scratch pad area ? 1024 bytes at location 0xfc00 to 0xffff are reserved.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 179 16.3. security options the cip-51 provides security options to protect the flash memory from inadvertent modification by soft- ware as well as prevent the viewing of proprietary program code and constants. the program store write enable (psctl.0) and the program store erase enable (psctl.1) bits protect the flash memory from accidental modification by software. these bits must be explicitly set to logic 1 be fore software can write or erase the flash memory. additional se curity features prevent proprietary program code and data constants from being read or altered across the jtag interfac e or by software running on the system controller. a set of security lock bytes protect the flash program memory from being read or altered across the jtag interface. each bit in a security lock-byte protects one 8k-byte block of memory. clearing a bit to logic 0 in a read lock byte prevents the corresponding block of flash memory from being read across the jtag interface. clearing a bit in the writ e/erase lock byte protects the blo ck from jtag erasures and/or writes. the scratchpad area is read or write/ erase locked when all bits in t he corresponding security byte are cleared to logic 0. on the c8051f060/1/2/3/4/5, the security lock bytes are located at 0xfbfe (write/erase lock) and 0xfbff (read lock), as shown in figure 16.1. on the c8051f066/7, the security lock bytes are located at 0x7ffe (write/erase lock) and 0x7fff (read lock), as shown in figure 16.2. the 512-byte sector con- taining the lock bytes can be written to, but not erased, by software. an attempted read of a read-locked byte returns undefined data. debugging code in a read-locked sector is not possible through the jtag interface. the lock bits can always be read from and written to logic 0 regardle ss of the security setting applied to the block containing the security bytes. th is allows additional blocks to be protected after the block containing the security bytes has been locked. important note: to ensure protection from external access, the block containing the lock bytes must be write/erase locked. on the 64 k byte devices (c8051f060/1/2/3/4/5), the page containing the security bytes is 0xfa00-0xfbff, and is lock ed by clearing bit 7 of the write/erase lock byte. on the 32 k byte devices (c8051f066/7), the page containing the security bytes is 0x7e00-0x7fff, and is locked by clearing bit 3 of the write/erase lock byte. if the page containing the security bytes is not write/erase locked, it is still possible to erase this page of flash memory through the jtag port and reset the security bytes. when the page containing the security bytes has been write/erase locked, a jtag full device erase must be performed to unlock any areas of flash protected by the security bytes. a jtag full device erase is initiated by performing a normal jtag erase operation on either of the security byte locations. this operation must be initiated through the jtag port, and cannot be performed from firmware running on the device.
c8051f060/1/2/3/4/5/6/7 180 rev. 1.2 0xfc00 0xfbfe 0x0000 0xfbff read lock byte write/erase lock byte reserved 0xffff 0xfbfd sfle = 0 bit mem ory bloc k 7 6 5 4 0xc000 - 0xdfff 0xe000 - 0xfbfd 0xa000 - 0xbfff 0x8000 - 0x9fff 3 2 1 0 0x4000 - 0x5fff 0x6000 - 0x7fff 0x2000 - 0x3fff 0x0000 - 0x1fff read and write/erase security bits (bit 7 is msb) 0x007f 0x0000 sfle = 1 flash access limit program/data memory space scratchpad memory (data only) figure 16.1. c8051f060/1/2/3/4/5 flash program memory map and security bytes flash read lock byte bits7-0: each bit locks a correspondi ng block of memory. (bit7 is msb). 0: read operations are locked (disabled) fo r corresponding block across the jtag interface. 1: read operations are unlocked (enabled) fo r corresponding block across the jtag inter- face. flash write/erase lock byte bits7-0: each bit locks a corresponding block of memory. 0: write/erase operations are locked (disabled) for corresponding block across the jtag interface. 1: write/erase operations are unlocked (enabled) for corresponding block across the jtag interface. note: when the block containing the security bytes is locked, the security bytes may be written but not erased. flash access limit the flash access limit is defined by the sett ing of the flacl register, as described in figure 16.3. firmware running at or above this address is prohibited from using the movx and movc instructions to read, write, or erase flash locations below this address.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 181 the flash access limit security feature (see figure 16.3) protects proprietary program code and data from being read by software running on the c8051f060/1/2/3/4/5/6/7. this feature provides support for oems that wish to program the mcu with proprietary value- added firmware before dist ribution. the value-added firmware can be protected while allowing additional code to be programmed in remaining program memory space later. the flash access limit (fal) is a 16-bit address that establishes two logical partitions in the program memory space. the first is an upper partition consis ting of all the program memory locations at or above the fal address, and the second is a lower partition co nsisting of all the program memory locations start- 0x8000 0x7ffe 0x0000 0x7fff read lock byte write/erase lock byte reserved 0xffff 0x7ffd sfle = 0 bit mem ory b loc k 7 6 5 4 n/a n/a n/a n/a 3 2 1 0 0x4000 - 0x5fff 0x6000 - 0x7ffd 0x2000 - 0x3fff 0x0000 - 0x1fff read and write/erase security bits (bit 7 is msb) 0x007f 0x0000 sfle = 1 flash access limit program/data memory space scratchpad memory (data only) figure 16.2. c8051f066/7 flash progra m memory map and security bytes flash read lock byte bits7-0: each bit locks a corresponding block of memory. 0: read operations are locked (disabled) fo r corresponding block across the jtag interface. 1: read operations are unlocked (enabled) fo r corresponding block across the jtag inter- face. flash write/erase lock byte bits7-0: each bit locks a corresponding block of memory. 0: write/erase operations are locked (disabled) for corresponding block across the jtag interface. 1: write/erase operations are unlocked (enabled) for corresponding block across the jtag interface. note: when the block containing the security bytes is locked, the security bytes may be written but not erased. flash access limit register (flacl) the flash access limit is defined by the sett ing of the flacl register, as described in figure 16.3. firmware running at or above this address is prohibited from using the movx and movc instructions to read, write, or erase flash locations below this address.
c8051f060/1/2/3/4/5/6/7 182 rev. 1.2 ing at 0x0000 up to (but excluding) the fal address. software in the upper partition can execute code in the lower partition, but is prohibited from reading locations in th e lower partition using the movc instruc- tion. (executing a movc instruction from the upper pa rtition with a source address in the lower partition will always return a data value of 0x 00.) software running in the lower partition can a ccess locations in both the upper and lower partition without restriction. the value-added firmware should be placed in the lowe r partition. on reset, cont rol is passed to the value- added firmware via the reset vector. once the value- added firmware completes its initial execution, it branches to a predetermined location in the upper partition. if entry points are published, software running in the upper partition may execute program code in the lower partition, but it ca nnot read the contents of the lower partition. parameters may be passed to the program code running in the lower partition either through the typical method of placing them on the stack or in registers before the call or by placing them in prescribed memory locations in the upper partition. the fal address is specified using the contents of the flash access limit register. the 16-bit fal address is calculated as 0xnn00, where nn is the co ntents of the fal security register. thus, the fal can be located on 256-byte boundaries anywhere in program memory space. however, the 512-byte erase sector size essentially requires that a 512 boundary be used. the contents of a non-initialized fal security byte is 0x00, thereby setting the fal address to 0x0 000 and allowing read access to all locations in pro- gram memory space by default. bits 7-0: flacl: flash access limit. this register holds the high byte of the 16 -bit program memory read/write/erase limit address. the entire 16-bit access limit addre ss value is calculated as 0xnn00 where nn is replaced by contents of flacl. a write to th is register sets the flash access limit. this register can only be written once after any reset. any subsequent writes are ignored until the next reset. to fully protect all addresses below this limit, bit 0 of flacl should be set to ?0? to align the fal on a 512-byte flash page boundary . r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr address: sfr page: 0xb7 f figure 16.3. flacl: flash access limit
c8051f060/1/2/3/4/5/6/7 rev. 1.2 183 16.3.1. summary of flash security options there are three flash access methods supported on the c8051f060/1/2/3/4/5/ 6/7; 1) accessing flash through the jtag debug interface, 2) accessing fl ash from firmware residing below the flash access limit, and 3) accessing flash from firmware re siding at or above the flash access limit. accessing flash through the jtag debug interface: 1. the read and write/erase lock bytes (securit y bytes) provide secu rity for flash access through the jtag interface. 2. any unlocked page may be read from, written to, or erased. 3. locked pages cannot be read from, written to, or erased. 4. reading the security bytes is always permitted. 5. locking additional pages by writing to the security bytes is always permitted. 6. if the page containing the security bytes is unlocked , it can be directly erased. doing so will reset the security bytes and unlock all pages of flash. 7. if the page containing the security bytes is locked , it cannot be directly erased. to unlock the page containing the security bytes, a full jtag device erase is required. a full jtag device erase will erase all flash pages, includi ng the page containing the security bytes and the security bytes themselves. 8. the reserved area cannot be read from, written to, or erased at any time. accessing flash from firmware resi ding below the flash access limit: 1. the read and write/erase lock bytes (security bytes) do not restrict flash access from user firmware. 2. any page of flash except the page containing the security bytes may be read from, written to, or erased. 3. the page containing the security bytes cannot be erased. unlocking pages of flash can only be performed via the jtag interface. 4. the page containing the security bytes may be read from or written to. pages of flash can be locked from jtag access by wr iting to the se curity bytes. 5. the reserved area cannot be read from, written to, or erased at any time. accessing flash from firmware residing at or above the flash access limit: 1. the read and write/erase lock bytes (security bytes) do not restrict flash access from user firmware. 2. any page of flash at or above the flash access limit except the page containing the security bytes may be read from, written to, or erased. 3. any page of flash below the flash access limit cannot be read from, written to, or erased. 4. code branches to locations below the flash access limit are permitted. 5. the page containing the security bytes cannot be erased. unlocking pages of flash can only be performed via the jtag interface. 6. the page containing the security bytes may be read from or written to. pages of flash can be locked from jtag access by wr iting to the se curity bytes. 7. the reserved area cannot be read from, written to, or erased at any time.
c8051f060/1/2/3/4/5/6/7 184 rev. 1.2 figure 16.4. flscl: flash memory control bit 7: fose: flash on e-shot timer enable this is the timer that turns off the sense amps after a flash read. 0: flash one-shot timer disabled. 1: flash one-shot timer enabled (recommended setting.) bit 6: frae: flash read always enable 0: flash reads occur as necessary (recommended setting.). 1: flash reads occur every system clock cycle. bits 5-1: reserved. read = 00000b. must write 00000b. bit 0: flwe: flash write/erase enable this bit must be set to allow flash writes/erases from user software. 0: flash writes/erases disabled. 1: flash writes/erases enabled. r/w r/w r/w r/w r/w r/w r/w r/w reset value fose frae reserved reserved reserved reserved reserved flwe 10000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr address: sfr page: 0xb7 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 185 figure 16.5. psctl: program store read/write control bits 7-3: unused. read = 00000b, write = don't care. bit 2: sfle: scratchpad flash memory access enable when this bit is set, flash movc reads and wr ites from user software are directed to the 128-byte scratchpad flash sector. when sfle is set to logic 1, flash accesses out of the address range 0x 00-0x7f should not be atte mpted. reads/writes out of this range will yield undefined results. 0: flash access from user software directed to the program/data flash sector. 1: flash access from user software directed to the scratchpad sector. bit 1: psee: program store erase enable. setting this bit allows an entire page of th e flash program memory to be erased provided the pswe bit is also set. afte r setting this bit, a write to flash memory using the movx instruction will erase the entire page that contains the loca tion addressed by the movx instruction. the value of the data byte written does not matter. note: the flash page con- taining the read lock byte and write/erase lock byte cannot be erased by software. 0: flash program memory erasure disabled. 1: flash program memory erasure enabled. bit 0: pswe: program store write enable. setting this bit allows writing a byte of dat a to the flash program memory using the movx write instruction. the location must be erased prior to writing data. 0: write to flash program memory disabled. movx write operations target external ram. 1: write to flash program memory enabled. movx write operations target flash memory. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - - sfle psee pswe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr address: sfr page: 0x8f 0
c8051f060/1/2/3/4/5/6/7 186 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 187 17. external data memory interface and on-chip xram the c8051f060/1/2/3/4/5/6/7 mcus include 4 k bytes of on-chip ram mapped into the external data memory space (xram). in addition, the c8051f060/2/4/6 include an external data memory interface which can be used to access off-chip memories and memory-mapped devices connected to the gpio ports. the external memory space may be accessed us ing the external move instruction (movx) and the data pointer (dptr), or using the movx indirect addressing mode using r0 or r1. if the movx instruction is used with an 8-bit address operand (such as @r1), then the high byte of the 16-bit address is provided by the external memory interface control regist er (emi0cn, shown in figure 17.1). note: the movx instruction can also be used for writing to the flash memory. see section ?16. flash memory? on page 177 for details. the movx instructi on accesses xram by default. 17.1. accessing xram the xram memory space (both internal and extern al) is accessed using the movx instruction. the movx instruction has two forms, both of which use an indirect addressing method. the first method uses the data pointer, dptr, a 16-bit register which contai ns the effective address of the xram location to be read or written. the second method uses r0 or r1 in combination with the em i0cn register to generate the effective xram address. examples of both of these methods are given below. 17.1.1. 16-bit movx example the 16-bit form of the movx instructi on accesses the memory location pointed to by the contents of the dptr register. the following series of instructions reads the value of the byte at address 0x1234 into the accumulator a: mov dptr, #1234h ; load dptr with 16-bit address to read (0x1234) movx a, @dptr ; load contents of 0x1234 into accumulator a the above example uses the 16-bit immediate mov inst ruction to set the contents of dptr. alternately, the dptr can be accessed through the sfr registers dph, which contains the upper 8-bits of dptr, and dpl, which contains the lower 8-bits of dptr. 17.1.2. 8-bit movx example the 8-bit form of the movx instruction uses the cont ents of the emi0cn sfr to determine the upper 8-bits of the effective address to be accessed and the contents of r0 or r1 to determine the lower 8-bits of the effective address to be accessed. the following series of instructions read the contents of the byte at address 0x1234 into the accumulator a. mov emi0cn, #12h ; load high byte of address into emi0cn mov r0, #34h ; load low byte of address into r0 (or r1) movx a, @r0 ; load contents of 0x1234 into accumulator a
c8051f060/1/2/3/4/5/6/7 188 rev. 1.2 17.2. configuring the external memory interface configuring the external memory interface consists of four steps: 1. enable the emif on the high ports (p7, p6, p5, and p4). 2. configure the output modes of the port pins as either push-pull or open-drain (push-pull is most common). 3. configure port latches to ?park? the emif pins in a dormant state (usually by setting them to logic ?1?). 4. select multiplexed mode or non-multiplexed mode. 5. select the memory mode (on-chip only, split mode without bank select, split mode with bank select, or off-chip only). 6. set up timing to interface with off-chip memory or peripherals. each of these four steps is explained in detail in the following sections. the po rt enable bit, multiplexed mode selection, and mode bits are located in the emi0cf register shown in figure 17.2. 17.3. port selection and configuration when enabled, the external memory interface appears on ports 7, 6, 5, and 4 in non-multiplexed mode, or ports 7, 6, and 4 in multiplexed mode. the external memory interface claims the associated port pins for memory oper ations only during the execution of an off-chip movx instruction. once the movx instruction has completed, control of the port pins reverts to the port latches. see section ?18. port input/output? on page 203 for more information about the port operation and configuration. the port latches should be explicitly configured to ?park? the external memory interface pins in a dormant state when not in use, most commonly by setting them to a logic 1 . during the execution of the movx inst ruction, the external memory interf ace will explicitly disable the driv- ers on all port pins that are acting as inputs (dat a[7:0] during a read operati on, for example). the output mode of the port pins (whether the pin is configured as open-drain or push-pull) is unaffected by the external memory interface operation, and rema ins controlled by the pnmdout registers. see section ?18. port input/output? on page 203 for more information about port output mode configuration.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 189 figure 17.1. emi0cn: external memory interface control bits7-0: pgsel[7:0]: xr am page select bits. the xram page select bits provide the high byte of the 16-bit external data memory address when using an 8-bit movx command, effectively selecting a 256-byte page of ram. 0x00: 0x0000 to 0x00ff 0x01: 0x0100 to 0x01ff ... 0xfe: 0xfe00 to 0xfeff 0xff: 0xff00 to 0xffff r/w r/w r/w r/w r/w r/w r/w r/w reset value pgsel7 pgsel6 pgsel5 pgsel4 pg sel3 pgsel2 pgsel1 pgsel0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa2 0 figure 17.2. emi0cf: external memory configuration bits7-6: unused. read = 00b. write = don?t care. bit5: prtsel: emif port select. 0: emif not mapped to port pins. 1: emif active on p4-p7. bit4: emd2: emif multiplex mode select. 0: emif operates in multiplexed address/data mode. 1: emif operates in non-multiplexed mode (separate address and data pins). bits3-2: emd1-0: emif operating mode select. these bits control the operating mode of the external memory interface. 00: internal only: movx accesses on-chip xram only. all effective addresses alias to on-chip memory space. 01: split mode without bank select: accesses below the 4 kb boundary are directed on-chip. accesses above the 4 kb boundary are directed off-chip. 8-bit off-chip movx operations use the current contents of the address high port latches to resolve upper address byte. note that in order to access off-chip space, emi0cn must be set to a page that is not contained in the on-chip address space. 10: split mode with bank select: accesses below the 4 kb boundary are directed on-chip. accesses above the 4 kb boundary are directed off-chip. 8-bit off-chip movx operations use the contents of emi0cn to determine the high-byte of the address. 11: external only: movx accesses off-chip xram only. on-chip xram is not visible to the cpu. bits1-0: eale1-0: ale pulse-width select bits (only has effect when emd2 = 0). 00: ale high and ale low pulse width = 1 sysclk cycle. 01: ale high and ale low pulse width = 2 sysclk cycles. 10: ale high and ale low pulse width = 3 sysclk cycles. 11: ale high and ale low pulse width = 4 sysclk cycles. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - prtsel emd2 emd1 emd0 eale1 eale0 00000011 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa3 0
c8051f060/1/2/3/4/5/6/7 190 rev. 1.2 17.4. multiplexed and non-multiplexed selection the external memory interface is capable of acting in a multiplexe d mode or a non-multiplexed mode, depending on the state of the emd2 (emi0cf.4) bit. 17.4.1. multiplexed configuration in multiplexed mode, the data bus and the lower 8-bits of the address bus share the same port pins: ad[7:0]. in this mode , an external latch (74hc373 or equivalent logic gate) is used to hold the lower 8-bits of the ram address. the external latch is controlle d by the ale (address latch enable) signal, which is driven by the external memory interface logic. an example of a multiplexed configuration is shown in figure 17.3. in multiplexed mode, the external movx operation can be broken into two phases delineated by the state of the ale signal. during the first phase, ale is high and the lower 8-bits of the address bus are pre- sented to ad[7:0]. during this phase , the address latch is configured such that the ?q? outputs reflect the states of the ?d? inputs. when ale falls, signaling th e beginning of the second phase, the address latch outputs remain fixed and are no longer dependent on the latch inputs. later in the second phase, the data bus controls the state of the ad[7:0] port at the time /rd or /wr is asserted. see section ?17.6.2. multiplexed mode? on page 199 for more information. address/data bus address bus e m i f a[15:8] (p6) ad[7:0] (p7) /wr (p4.7) /rd (p4.6) ale (p4.5) 64k x 8 sram oe we i/o[7:0] 74hc373 g dq a[15:8] a[7:0] ce v dd 8 (optional) figure 17.3. multiplexed configuration example
c8051f060/1/2/3/4/5/6/7 rev. 1.2 191 17.4.2. non-multiplexed configuration in non-multiplexed mode, the data bus and the addr ess bus pins are not shared. an example of a non- multiplexed configuration is shown in figure 17.4. see section ?17.6.1. non-multiplexed mode? on page 196 for more information about non-multiplexed operation. address bus e m i f a[15:0] (p5 and p6) 64k x 8 sram a[15:0] data bus d[7:0] (p7) i/o[7:0] v dd 8 /wr (p4.7) /rd (p4.6) oe we ce (optional) figure 17.4. non-multiplexed configuration example
c8051f060/1/2/3/4/5/6/7 192 rev. 1.2 17.5. memory mode selection the external data memory space can be configured in one of four modes, shown in figure 17.5, based on the emif mode bits in the emi0cf register (figure 17.2). these modes are summarized below. more infor- mation about the different modes can be found in section ?17.6. timing? on page 194 . 17.5.1. internal xram only when emi0cf.[3:2] are set to ?00?, all movx instructions will ta rget the internal xram space on the device. memory accesses to address es beyond the po pulated space will wrap on 4 k byte boundaries. as an example, the addresses 0x1000 and 0x2000 both ev aluate to address 0x0000 in on-chip xram space. ? 8-bit movx operations use the contents of emi0cn to determine the high-byte of the effective address and r0 or r1 to determine the lo w-byte of the effective address. ? 16-bit movx operations use the contents of the 16-bit dptr to determine the effective address. 17.5.2. split mode without bank select when emi0cf.[3:2] are set to ?01?, the xram memory map is split into two areas, on-chip space and off- chip space. ? effective addresses below the 4 kb bo undary will access on-chip xram space. ? effective addresses beyond the 4 kb boundary will access off-chip space. ? 8-bit movx operations use the contents of emi0 cn to determine whether the memory access is on- chip or off-chip. however, in th e ?no bank select? mode, an 8-bi t movx operation will not drive the upper 8-bits a[15:8] of the address bus during an off-chip access. this allows the user to manipulate the upper address bits at will by setting the port state directly. this behavior is in contrast with ?split mode with bank select? described below. the lower 8- bits of the address bus a[7:0] are driven, deter- mined by r0 or r1. ? 16-bit movx operations use the contents of dptr to determine whether the memory access is on- chip or off-chip, and unlike 8-bit movx operations, the full 16-bits of the address bus a[15:0] are driven during the off-chip transaction. emi0cf[3:2] = 00 0xffff 0x0000 emi0cf[3:2] = 11 0xffff 0x0000 emi0cf[3:2] = 01 0xffff 0x0000 emi0cf[3:2] = 10 on-chip xram on-chip xram on-chip xram on-chip xram on-chip xram on-chip xram off-chip memory (no bank select) on-chip xram 0xffff 0x0000 off-chip memory (bank select) on-chip xram off-chip memory figure 17.5. emif operating modes
c8051f060/1/2/3/4/5/6/7 rev. 1.2 193 17.5.3. split mode with bank select when emi0cf.[3:2] are set to ?10?, the xram memory map is split into two areas, on-chip space and off- chip space. ? effective addresses below the 4 kb bo undary will access on-chip xram space. ? effective addresses beyond the 4 kb boundary will access off-chip space. ? 8-bit movx operations use the contents of emi0 cn to determine whether the memory access is on- chip or off-chip. the upper 8-bits of the address bus a[15:8] are determined by emi0cn, and the lower 8-bits of the address bus a[7:0] are determined by r0 or r1. all 16-bits of the address bus a[15:0] are driven in ?bank select? mode. ? 16-bit movx operations use the contents of dptr to determine whether the memory access is on- chip or off-chip, and the full 16-bits of the addre ss bus a[15:0] are driven during the off-chip transac- tion. 17.5.4. external only when emi0cf[3:2] are set to ?11?, all movx operations are directed to off-chip space. on-chip xram is not visible to the cpu. this mode is useful for ac cessing off-chip memory located between 0x0000 and the 4 kb boundary. ? 8-bit movx operations ignore the contents of emi0 cn. the upper address bits a[15:8] are not driven (identical behavior to an off-chip access in ?split mode without bank select? described above). this allows the user to manipulate the upp er address bits at will by setting the port state directly. the lower 8-bits of the effective address a[7:0] are determined by the contents of r0 or r1. ? 16-bit movx operations use the contents of dptr to determine the effective address a[15:0]. the full 16-bits of the address bus a[15:0] are driven during the off-chip transaction.
c8051f060/1/2/3/4/5/6/7 194 rev. 1.2 17.6. timing the timing parameters of the external memory in terface can be configured to enable connection to devices having different setup and hold time requirements. the address setup time, address hold time, / rd and /wr strobe widths, and in multiplexed mode, the width of the ale pulse are all programmable in units of sysclk periods th rough emi0tc, shown in fi gure 17.6, and emi0cf[1:0]. the timing for an off-chip movx instruction can be calculated by adding 4 sysclk cycles to the timing parameters defined by the emi0tc register. assumi ng non-multiplexed operation, the minimum execution time for an off-chip xram operat ion is 5 sysclk cycles (1 sysclk for /rd or /wr pulse + 4 sysclks). for multiplexed oper ations, the address latch enable signal will require a minimum of 2 additional sysclk cycles. therefore, the minimum execution time for an off-chip xram operation in multiplexed mode is 7 sysclk cycles (2 for /ale + 1 for /rd or /wr + 4). the programm able setup and hold times default to the maximum delay settings after a reset. figure 17.6. emi0tc: external memory timing control bits7-6: eas1-0: emif address setup time bits. 00: address setup time = 0 sysclk cycles. 01: address setup time = 1 sysclk cycle. 10: address setup time = 2 sysclk cycles. 11: address setup time = 3 sysclk cycles. bits5-2: ewr3-0: emif /wr and /rd pulse-width control bits. 0000: /wr and /rd pulse width = 1 sysclk cycle. 0001: /wr and /rd pulse width = 2 sysclk cycles. 0010: /wr and /rd pulse width = 3 sysclk cycles. 0011: /wr and /rd pulse width = 4 sysclk cycles. 0100: /wr and /rd pulse width = 5 sysclk cycles. 0101: /wr and /rd pulse width = 6 sysclk cycles. 0110: /wr and /rd pulse width = 7 sysclk cycles. 0111: /wr and /rd pulse width = 8 sysclk cycles. 1000: /wr and /rd pulse width = 9 sysclk cycles. 1001: /wr and /rd pulse wid th = 10 sysclk cycles. 1010: /wr and /rd pulse width = 11 sysclk cycles. 1011: /wr and /rd pulse width = 12 sysclk cycles. 1100: /wr and /rd pulse width = 13 sysclk cycles. 1101: /wr and /rd pulse width = 14 sysclk cycles. 1110: /wr and /rd pulse width = 15 sysclk cycles. 1111: /wr and /rd pulse width = 16 sysclk cycles. bits1-0: eah1-0: emif address hold time bits. 00: address hold time = 0 sysclk cycles. 01: address hold time = 1 sysclk cycle. 10: address hold time = 2 sysclk cycles. 11: address hold time = 3 sysclk cycles. r/w r/w r/w r/w r/w r/w r/w r/w reset value eas1 eas0 erw3 ewr2 ewr1 ewr0 eah1 eah0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa1 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 195 table 17.1 lists the ac parameters for the exter nal memory interface, and figure 17.7 through figure 17.12 show the timing diagrams for the different external memory interface modes and movx operations.
c8051f060/1/2/3/4/5/6/7 196 rev. 1.2 17.6.1. non-multiplexed mode 17.6.1.1.16-bit movx: emi0cf[4:2] = ?101?, ?110?, or ?111?. emif address (8 msbs) from dph emif address (8 lsbs) from dpl p6 p5 p4.7 p4.6 p7 emif write data p6 p5 p4.7 p4.6 p7 t ach t wdh t acw t acs t wds addr[15:8] addr[7:0] data[7:0] /wr /rd emif address (8 msbs) from dph emif address (8 lsbs) from dpl p6 p5 p4.6 p4.7 p7 p6 p5 p4.6 p4.7 p7 t ach t rdh t acw t acs t rds addr[15:8] addr[7:0] data[7:0] /rd /wr emif read data nonmuxed 16-bit write nonmuxed 16-bit read figure 17.7. non-multipl exed 16-bit movx timing
c8051f060/1/2/3/4/5/6/7 rev. 1.2 197 17.6.1.2.8-bit movx without bank select: emi0cf[4:2] = ?101? or ?111?. emif address (8 lsbs) from r0 or r1 p6 p5 p4.7 p4.6 p7 emif write data p6 p4.7 p4.6 p7 t ach t wdh t acw t acs t wds addr[15:8] addr[7:0] data[7:0] /wr /rd emif address (8 lsbs) from r0 or r1 p6 p5 p4.6 p4.7 p7 p6 p4.6 p4.7 p7 t ach t rdh t acw t acs t rds addr[15:8] addr[7:0] data[7:0] /rd /wr emif read data nonmuxed 8-bit write without bank select nonmuxed 8-bit read without bank select figure 17.8. non-multiplexed 8-bit movx without bank select timing
c8051f060/1/2/3/4/5/6/7 198 rev. 1.2 17.6.1.3.8-bit movx with bank select: emi0cf[4:2] = ?110?. emif address (8 msbs) from emi0cn emif address (8 lsbs) from r0 or r1 p6 p5 p4.7 p4.6 p7 emif write data p6 p5 p4.7 p4.6 p7 t ach t wdh t acw t acs t wds addr[15:8] addr[7:0] data[7:0] /wr /rd emif address (8 msbs) from emi0cn emif address (8 lsbs) from r0 or r1 p6 p5 p4.6 p4.7 p7 p6 p5 p4.6 p4.7 p7 t ach t rdh t acw t acs t rds addr[15:8] addr[7:0] data[7:0] /rd /wr emif read data nonmuxed 8-bit write with bank select nonmuxed 8-bit read with bank select figure 17.9. non-multiplexed 8-bit movx with bank select timing
c8051f060/1/2/3/4/5/6/7 rev. 1.2 199 17.6.2. multiplexed mode 17.6.2.1.16-bit movx: emi0cf[4:2] = ?001 ?, ?010?, or ?011?. p7 p6 p7 addr[15:8] ad[7:0] p6 p4.7 p4.6 p4.5 p4.7 p4.6 p4.5 t ach t wdh t acw t acs t wds ale /wr /rd emif address (8 msbs) from dph emif write data emif address (8 lsbs) from dpl t aleh t alel p7 p6 p7 addr[15:8] ad[7:0] p6 p4.6 p4.7 p4.5 p4.6 p4.7 p4.5 t ach t acw t acs ale /rd /wr emif address (8 msbs) from dph emif address (8 lsbs) from dpl t aleh t alel t rdh t rds emif read data muxed 16-bit write muxed 16-bit read figure 17.10. multiplexe d 16-bit movx timing
c8051f060/1/2/3/4/5/6/7 200 rev. 1.2 17.6.2.2.8-bit movx without bank select: emi0cf[4:2] = ?001? or ?011?. p7 p6 p7 addr[15:8] ad[7:0] p4.7 p4.6 p4.5 p4.7 p4.6 p4.5 t ach t wdh t acw t acs t wds ale /wr /rd emif write data emif address (8 lsbs) from r0 or r1 t aleh t alel p7 p6 p7 addr[15:8] ad[7:0] p4.6 p4.7 p4.5 p4.6 p4.7 p4.5 t ach t acw t acs ale /rd /wr emif address (8 lsbs) from r0 or r1 t aleh t alel t rdh t rds emif read data muxed 8-bit write without bank select muxed 8-bit read without bank select figure 17.11. multiplexed 8-bit movx without bank select timing
c8051f060/1/2/3/4/5/6/7 rev. 1.2 201 17.6.2.3.8-bit movx with bank select: emi0cf[4:2] = ?010?. p7 p6 p7 addr[15:8] ad[7:0] p6 p4.7 p4.6 p4.5 p4.7 p4.6 p4.5 t ach t wdh t acw t acs t wds ale /wr /rd emif address (8 msbs) from emi0cn emif write data emif address (8 lsbs) from r0 or r1 t aleh t alel p7 p6 p7 addr[15:8] ad[7:0] p6 p4.6 p4.7 p4.5 p4.6 p4.7 p4.5 t ach t acw t acs ale /rd /wr emif address (8 msbs) from emi0cn emif address (8 lsbs) from r0 or r1 t aleh t alel t rdh t rds emif read data muxed 8-bit write with bank select muxed 8-bit read with bank select figure 17.12. multiplexed 8-bit movx with bank select timing
c8051f060/1/2/3/4/5/6/7 202 rev. 1.2 table 17.1. ac parameters for external memory interface parameter description min max units t sysclk system clock period 40 ns t acs address / control setup time 0 3*t sysclk ns t acw address / control pulse width 1*t sysclk 16*t sysclk ns t ach address / control hold time 0 3*t sysclk ns t aleh address latch enable high time 1*t sysclk 4*t sysclk ns t alel address latch enable low time 1*t sysclk 4*t sysclk ns t wds write data setup time 1*t sysclk 19*t sysclk ns t wdh write data hold time 0 3*t sysclk ns t rds read data setup time 20 ns t rdh read data hold time 0 ns
c8051f060/1/2/3/4/5/6/7 rev. 1.2 203 18. port input/output the c8051f06x family of devices are fully integrated mixed-signal system on a chip mcus with 59 digital i/o pins (c8051f060/2/4/6) or 24 digital i/o pins (c80 51f061/3/5/7), organized as 8-bit ports. all ports are both bit- and byte-addressable through their correspondi ng port data registers. all port pins support con- figurable open-drain or push-pull output modes and we ak pull-ups. additionally, port 0 pins are 5 v-toler- ant. a block diagram of the port i/o cell is shown in figure 18.1. complete electric al specifications for the port i/o pins are given in table 18.1. dgnd /port-outenable port-output push-pull vdd vdd /weak-pullup (weak) port pad analog input analog select (port 1 and 2 only) port-input figure 18.1. port i/o cell block diagram table 18.1. port i/o dc electrical characteristics vdd = 2.7 to 3.6 v, -40 to +85 c unless otherwise specified. parameter conditions min typ max units output high voltage (v oh ) i oh = -3 ma, port i/o push-pull i oh = -10 a, port i/o push-pull vdd - 0.7 vdd - 0.1 v output low voltage (v ol ) i ol = 8.5 ma i ol = 10 a 0.6 0.1 v input high voltage (vih) 0.7 x vdd input low voltage (vil) 0.3 x vdd input leakage current dgnd < port pin < vdd, pin tri-state weak pull-up off weak pull-up on 10 1 a a input capacitance 5 pf
c8051f060/1/2/3/4/5/6/7 204 rev. 1.2 the c8051f06x family of devices hav e a wide array of digital resources which are available through the four lower i/o ports: p0, p1, p2, and (on the c8051f060/2/4/6) p3. each of the pins on p0, p1, p2, and p3, can be defined as a general-purpose i/o (gpio) pin or can be controlled by a digital peripheral or function (like uart0 or /int1 for example), as show n in figure 18.2. the syste m designer controls which digital functions are assigned pins, limited only by the number of pins available. this resource assignment flexibility is achieved through the use of a priority crossbar decoder. note that the state of a port i/o pin can always be read from its associated data register regardless of whether that pin has been assigned to a digital peripheral or behaves as gpio. the port pins on port 2 can be used as analog inputs to the ana- log voltage comparators. on the c8051f060/1/2/3, the pins of port 1 can be used as analog inputs for adc2. the upper ports (available on c8051f060/2/4/6) can be byte-accessed as gpio pins, or used as part of an external memory interface which is active duri ng a movx instruction whose target address resides in off-chip memory. see section ?17. external data memory interface and on-chip xram? on page 187 for more information about the external memory interface. external pins digital crossbar priority decoder smbus 2 spi 4 uart0 2 pca 2 t0, t1, t2, t2ex, t3, t3ex, t4,t4ex, /int0, /int1 p1.0 p1.7 p2.0 p2.7 p0.0 p0.7 highest priority lowest priority 8 8 comptr. outputs (internal digital signals) highest priority lowest priority uart1 6 2 p3.0 p3.7 8 8 p0mdout, p1mdout, p2mdout, p3mdout registers xbr0, xbr1, xbr2, xbr3 p1mdin, p2mdin, p3mdin registers p1 i/o cells p3 i/o cells p0 i/o cells p2 i/o cells 8 port latches p0 p1 p2 8 8 8 p3 8 (p2.0-p2.7) (p1.0-p1.7) (p0.0-p0.7) (p3.0-p3.7) to adc2 input to comparators /sysclk cnvstr2 c8051f060/2 only figure 18.2. port i/o functional block diagram
c8051f060/1/2/3/4/5/6/7 rev. 1.2 205 18.1. ports 0 through 3 and the priority crossbar decoder the priority crossbar decoder, or ?crossbar?, allo cates and assigns port pins on port 0 through port 3 to the digital peripherals (uarts, smbus, pca, timers, etc.) on the device using a priority order. the port pins are allocated in order starting with p0.0 and continue through p3.7 (on the c8051f060/2/4/6) or p2.7 (on the c8051f061/3/5/7) if necessary. the digital peripherals are assigned port pins in a priority order which is listed in figure 18.3, with uart0 having the highest priority and cnvstr2 having the lowest pri- ority. 18.1.1. crossbar pin assignment and allocation the crossbar assigns port pins to a peripheral if the corresponding enable bits of the peripheral are set to a logic 1 in the crossbar configuration registers xbr0, xbr1, xbr2, and xbr3, shown in figure 18.5, figure 18.6, figure 18.7, and figure 18.8. for example, if the uart0en bit (xbr0.2) is set to a logic 1, the tx0 and rx0 pins will be mapped to p0.0 and p0 .1 respectively. because uart0 has the highest pri- ority, its pins will always be mapped to p0.0 and p0.1 when uart0en is set to a logic 1. if a digital periph- figure 18.3. priority crossbar decode table (p1mdin = 0xff; p2mdin = 0xff) pin i/o 01234567012345670123456701234567 tx0 rx0 sck miso mosi nss nss is not assigned to a port pin when the spi is placed in 3-wire mode sda scl tx1 rx1 cex0 cex1 cex2 cex3 cex4 cex5 eci eci0e: xbr0.6 cp0 cp0e: xbr0.7 cp1 cp1e: xbr1.0 cp2 cp2e: xbr3.3 t0 t0e: xbr1.1 /int0 int0e: xbr1.2 t1 t1e: xbr1.3 /int1 int1e: xbr1.4 t2 t2e: xbr1.5 t2ex t2exe: xbr1.6 t3 t3e: xbr3.0 t3ex t3exe: xbr3.1 t4 t4e: xbr2.3 t4ex t4exe: xbr2.4 /sysclk syscke: xbr1.7 cnvstr2 cnvste2: xbr3.2 ain2.0 ain2.1 ain2.2 ain2.3 ain2.4 ain2.5 ain2.6 ain2.7 cp1+ cp1- cp2+ cp2- cp0+ cp0- xbr2.2 xbr0.[5:3] uart0en: spi0en: uart1en: pca0me: crossbar register bits xbr0.2 xbr0.1 xbr0.0 smb0en: p0 p1 p2 p3
c8051f060/1/2/3/4/5/6/7 206 rev. 1.2 eral?s enable bits are not set to a logic 1, then its ports are not accessible at the port pins of the device. also note that the crossbar assigns pins to all associated functions when the smbus, uart0 or uart1 are selected (i.e. smbus, spi, uart). it would be impo ssible, for example, to assign tx0 to a port pin without assigning rx0 as well. the spi can operate in 3 or 4-wire mode (with or without nss). each com- bination of enabled peripherals results in a unique device pinout. all port pins on ports 0 through 3 that are not allocated by the crossbar can be accessed as general-pur- pose i/o (gpio) pins by reading and writing the associated port data registers (see figure 18.9, figure 18.11, figure 18.14, and figure 18.17), a set of sfrs which are both byte- and bit-addressable. the output states of port pi ns that are allocated by the crossbar ar e controlled by the digital peripheral that is mapped to those pins. writes to the port data re gisters (or associated port bits) will have no effect on the states of these pins. a read of a port data register (or port bit) will always return the logic st ate present at the pin itself, regard- less of whether the crossbar has allocated the pin for peripheral use or not. an exception to this occurs during the execution of a read-modify-write instruction (anl, orl, xrl, cpl, inc, dec, djnz, jbc, clr, setb, and the bitwise mov write operation). during the read cycle of the read-modify-write instruc- tion, it is the contents of the port data register, no t the state of the port pins themselves, which is read. because the crossbar registers affect the pinout of the peripherals of the device, they are typically config- ured in the initialization code of th e system before the peripherals themselves are configured. once config- ured, the crossbar registers are typically left alone. once the crossbar registers have been properly co nfigured, the crossbar is enabled by setting xbare (xbr2.4) to a logic 1. until xbare is set to a logic 1, the output drivers on ports 0 through 3 are explicitly disabled in order to prevent possible contention on the port pins while the crossbar reg- isters and other registers which can affect the device pinout are being written . the output drivers on crossbar-assigned input signals ( like rx0, for example) are explicitly disabled; thus the values of the port data registers and the pnmd out registers have no effect on the states of these pins. 18.1.2. configuring the output modes of the port pins the output drivers on ports 0 through 3 remain disabl ed until the crossbar is enabled by setting xbare (xbr2.4) to a logic 1. the output mode of each port pin can be configured to be either open-drain or push-pull. in the push-pull configuration, writing a logic 0 to the associated bit in the port data register will cause the port pin to be driven to gnd, and writing a logic 1 will cause the port pin to be driven to vdd. in the open-drain configu- ration, writing a logic 0 to the associat ed bit in the port data register w ill cause the port pin to be driven to gnd, and a logic 1 will cause the port pin to assume a high-impedance state. the open-drain configura- tion is useful to prevent contention between devices in systems wher e the port pin participates in a shared interconnection in which multiple ou tputs are connected to the same ph ysical wire (like the sda signal on an smbus connection). the output modes of the port pins on ports 0 through 3 are determined by the bits in the associated pnm- dout registers (see figure 18.10, figure 18.13, figu re 18.16, and figure 18.18). for example, a logic 1 in p3mdout.7 will configure t he output mode of p3.7 to push-pull; a logic 0 in p3mdout.7 will configure the output mode of p3.7 to open-drain. all port pins default to open-drain output.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 207 the pnmdout registers control the out put modes of the port pins regard less of whether the crossbar has allocated the port pin for a digital peripheral or not. th e exceptions to this rule are: the port pins connected to sda, scl, rx0 (if uart0 is in mode 0), and rx 1 (if uart1 is in mode 0) are always configured as open-drain outputs, regardless of the settings of the associated bits in the pnmdout registers. 18.1.3. configuring port pins as digital inputs a port pin is configured as a digital input by setting its output mode to ?open-drain? and writing a logic 1 to the associated bit in the port data register. for exampl e, p3.7 is configured as a digital input by setting p3mdout.7 to a logic 0 and p3.7 to a logic 1. if the port pin has been assigned to a digital peripheral by the crossbar and that pin functions as an input (for example rx0, the uart0 receive pin), then the ou tput drivers on that pin are automatically disabled. 18.1.4. weak pull-ups by default, each port pin has an internal weak pu ll-up device enabled which pr ovides a resistive connec- tion (about 100 k ? ) between the pin and vdd. the weak pull-up devices can be globally disabled by writ- ing a logic 1 to the weak pull-up disable bit, (weakpud, xbr2.7). the weak pull-up is automatically deactivated on any pin that is driv ing a logic 0; that is, an output pin will not contend with its own pull-up device. the weak pull-up device can also be explicitly disabled on a port 1 pin by configuring the pin as an analog input, as described below. 18.1.5. configuring port 1 and 2 pins as analog inputs the pins on port 1 can serve as analog inputs to the adc2 analog mux (c8051f060/1/2/3 only) and the pins on port 2 can serve as analog inputs to the comparators (all devices). a port pin is configured as an analog input by writing a logic 0 to the associated bit in the pnmdin registers. all port pins default to a digital input mode. configuring a port pin as an analog input: 1. disables the digital input path from the pin. th is prevents additional power supply current from being drawn when the voltage at the pin is near vdd / 2. a read of the port data bit will return a logic 0 regardless of the voltage at the port pin. 2. disables the weak pull-up device on the pin. 3. causes the crossbar to ?skip over? the pin when allocating port pins for digital peripherals. note that the output drivers on a pin configured as an analog input are not explicitly disabled. therefore, the associated pnmdout bits of pins configured as analog inputs should explicitly be set to logic 0 (open-drain output mode), and the as sociated port data bits should be set to logic 1 (high-impedance). also note that it is not required to configure a port pi n as an analog input in order to use it as an input to adc2 or the comparators, however, it is strongly recommended. see the analog peripheral?s correspond- ing section in this datash eet for further information.
c8051f060/1/2/3/4/5/6/7 208 rev. 1.2 18.1.6. crossbar pin assignment example in this example (figure 18.4), we configure the crossbar to allocate port pins for uart0, the smbus, all 6 pca modules, /int0, and /int1 (12 pins total). additi onally, we configure p1.2, p1.3, and p1.4 for analog input mode so that the voltages at these pins can be measured by adc2. the configuration steps are as follows: xbr0, xbr1, and xbr2 are set such that uart 0en = 1, smb0en = 1, pca0me = ?110?, int0e = 1, and int1e = 1. thus: xbr0 = 0x3d, xbr1 = 0x14, and xbr2 = 0x40. 1. we configure the desired port 1 pins to analog input mode by setting p1mdin to 0xe3 (p1.4, p1.3, and p1.2 are analog inputs, so their associated p1mdin bits are set to logic 0). 2. we enable the crossbar by setting xbare = 1: xbr2 = 0x40. - uart0 has the highest priority, so p0.0 is assigned to tx0, and p0.1 is assigned to rx0. - the smbus is next in priority order, so p0.2 is assigned to sda, and p0.3 is assigned to scl. - pca0 is next in priority order, so p0.4 through p1.1 are assigned to cex0 through cex5 - p1mdin is set to 0xe3, which configures p1 .2, p1.3, and p1.4 as analog inputs, causing the crossbar to skip these pins. - /int0 is next in priority order, so it is assi gned to the next non-skipped pin, which is p1.5. - /int1 is next in priority order, so it is assigned to p1.6. 3. we set the uart0 tx pin (tx0, p0.0) output and the cex0-3 outputs to push-pull by setting p0mdout = 0xf1. 4. we explicitly disable the outp ut drivers on the 3 analog input pins by setting the corresponding bits in the p1mdout register to ?0?, and in p1 to ?1?. additionally, the cex5-4 output pins are set to push-pull mode. therefore, p1mdout = 0x 03 (configure unused pins to open-drain) and p1 = 0xff (a logic 1 selects the high-impedance state).
c8051f060/1/2/3/4/5/6/7 rev. 1.2 209 figure 18.4. crossbar example: (p1mdin = 0xe3; xbr0 = 0x3d; xbr1 = 0x14; xbr2 = 0x40) pin i/o 01234567012345670123456701234567 tx0 rx0 sck miso mosi nss sda scl tx1 rx1 cex0 cex1 cex2 cex3 cex4 cex5 eci eci0e: xbr0.6 cp0 cp0e: xbr0.7 cp1 cp1e: xbr1.0 cp2 cp2e: xbr3.3 t0 t0e: xbr1.1 /int0 int0e: xbr1.2 t1 t1e: xbr1.3 /int1 int1e: xbr1.4 t2 t2e: xbr1.5 t2ex t2exe: xbr1.6 t3 t3e: xbr3.0 t3ex t3exe: xbr3.1 t4 t4e: xbr2.3 t4ex t4exe: xbr2.4 /sysclk syscke: xbr1.7 cnvstr2 cnvste2: xbr3.2 ain2.0 ain2.1 ain2.2 ain2.3 ain2.4 ain2.5 ain2.6 ain2.7 cp1+ cp1- cp2+ cp2- cp0+ cp0- p0 p1 p2 p3 crossbar register bits xbr0.2 xbr0.1 xbr0.0 smb0en: xbr2.2 xbr0.[5:3] uart0en: spi0en: uart1en: pca0me:
c8051f060/1/2/3/4/5/6/7 210 rev. 1.2 figure 18.5. xbr0: port i/o crossbar register 0 bit7: cp0e: comparator 0 output enable bit. 0: cp0 unavailable at port pin. 1: cp0 routed to port pin. bit6: eci0e: pca0 external counter input enable bit. 0: pca0 external counter in put unavailable at port pin. 1: pca0 external co unter input (eci0) r outed to port pin. bits5-3: pca0me: pca0 mo dule i/o enable bits. 000: all pca0 i/o unavailable at port pins. 001: cex0 routed to port pin. 010: cex0, cex1 routed to 2 port pins. 011: cex0, cex1, and cex2 routed to 3 port pins. 100: cex0, cex1, cex2, and c ex3 routed to 4 port pins. 101: cex0, cex1, cex2, cex3, and cex4 routed to 5 port pins. 110: cex0, cex1, cex2, cex3, cex4, and cex5 routed to 6 port pins. bit2: uart0en: uart0 i/o enable bit. 0: uart0 i/o unavailable at port pins. 1: uart0 tx routed to p0.0 , and rx routed to p0.1. bit1: spi0en: spi0 bus i/o enable bit. 0: spi0 i/o unavailable at port pins. 4-wire mode: 1: spi0 sck, miso, mosi, and nss routed to 4 port pins. 3-wire mode: 1: spi0 sck, miso and mosi routed to 3 port pins. bit0: smb0en: smbus0 bus i/o enable bit. 0: smbus0 i/o unavailable at port pins. 1: smbus0 sda and scl routed to 2 port pins. r/w r/w r/w r/w r/w r/w r/w r/w reset value cp0e eci0e pca0me uart0en spi0en smb0en 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe1 f
c8051f060/1/2/3/4/5/6/7 rev. 1.2 211 figure 18.6. xbr1: port i/o crossbar register 1 bit7: syscke: /sysclk output enable bit. 0: /sysclk unavailable at port pin. 1: /sysclk routed to port pin. bit6: t2exe: t2ex input enable bit. 0: t2ex unavailable at port pin. 1: t2ex routed to port pin. bit5: t2e: t2 input enable bit. 0: t2 unavailable at port pin. 1: t2 routed to port pin. bit4: int1e: /int1 input enable bit. 0: /int1 unavailable at port pin. 1: /int1 routed to port pin. bit3: t1e: t1 input enable bit. 0: t1 unavailable at port pin. 1: t1 routed to port pin. bit2: int0e: /int0 input enable bit. 0: /int0 unavailable at port pin. 1: /int1 routed to port pin. bit1: t0e: t0 input enable bit. 0: t0 unavailable at port pin. 1: t1 routed to port pin. bit0: cp1e: cp1 output enable bit. 0: cp1 unavailable at port pin. 1: cp1 routed to port pin. r/w r/w r/w r/w r/w r/w r/w r/w reset value syscke t2exe t2e int1e t1e int0e t0e cp1e 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe2 f
c8051f060/1/2/3/4/5/6/7 212 rev. 1.2 figure 18.7. xbr2: port i/o crossbar register 2 bit7: weakpud: weak pu ll-up disable bit. 0: weak pull-ups globally enabled. 1: weak pull-ups globally disabled. bit6: xbare: crossb ar enable bit. 0: crossbar disabled. all pins on ports 0, 1, 2, and 3, are forced to input mode. 1: crossbar enabled. bit5: unused. read = 0, write = don't care. bit4: t4exe: t4ex input enable bit. 0: t4ex unavailable at port pin. 1: t4ex routed to port pin. bit3: t4e: t4 input enable bit. 0: t4 unavailable at port pin. 1: t4 routed to port pin. bit2: uart1e: uart1 i/o enable bit. 0: uart1 i/o unavailable at port pins. 1: uart1 tx and rx routed to 2 port pins. bits1-0: reserved r/w r/w r/w r/w r/w r/w r/w r/w reset value weakpud xbare - t4exe t4e uart1e - - 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe3 f
c8051f060/1/2/3/4/5/6/7 rev. 1.2 213 figure 18.8. xbr3: port i/o crossbar register 3 bit7: ctxout: can transmit pin (ctx) output mode. 0: ctx pin output mode is configured as open-drain. 1: ctx pin output mode is configured as push-pull. bit6-4: reserved bit3: cp2e: cp2 output enable bit. 0: cp2 unavailable at port pin. 1: cp2 routed to port pin. bit2: cnvst2e: adc2 external convert start input enable bit. 0: cnvst2 for adc2 unavailable at port pin. 1: cnvst2 for adc2 r outed to port pin. bit1: t3exe: t3ex input enable bit. 0: t3ex unavailable at port pin. 1: t3ex routed to port pin. bit0: t3e: t3 input enable bit. 0: t3 unavailable at port pin. 1: t3 routed to port pin. r r r r/w r/w r/w r/w r/w reset value ctxout - - cp2e cnvst2e t3exe t3e 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xe4 f
c8051f060/1/2/3/4/5/6/7 214 rev. 1.2 figure 18.9. p0: port0 data register bits7-0: p0.[7:0]: port0 output latch bits. (write - output appears on i/o pins per xbr0, xbr1, xbr2, and xbr3 registers) 0: logic low output. 1: logic high output (open if corresponding p0mdout.n bit = 0). (read - regardless of xbr0, xbr1, xbr2, and xbr3 register settings). 0: p0.n pin is logic low. 1: p0.n pin is logic high. r/w r/w r/w r/w r/w r/w r/w r/w reset value p0.7 p0.6 p0.5 p0.4 p0.3 p0.2 p0.1 p0.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x80 all pages figure 18.10. p0mdout: port0 output mode register bits7-0: p0mdout.[7:0]: port0 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. note: sda, scl, and rx0 (when uart0 is in mode 0) and rx1 (when uart1 is in mode 0) are always configured as open-drain when they appear on port pins. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa4 f
c8051f060/1/2/3/4/5/6/7 rev. 1.2 215 figure 18.11. p1: port1 data register bits7-0: p1.[7:0]: port1 output latch bits. (write - output appears on i/o pins per xbr0, xbr1, xbr2, and xbr3 registers) 0: logic low output. 1: logic high output (open if corresponding p1mdout.n bit = 0). (read - regardless of xbr0, xbr1, xbr2, and xbr3 register settings). 0: p1.n pin is logic low. 1: p1.n pin is logic high. note: on the c8051f060/1/2/3, p1.[7:0] can be configured as inputs to adc2 as ain2.[7:0], in which case they are ?skipped? by the crossbar assignment process and their digital input paths are disabled, depending on p1mdin (see figure 18.12 ) . note that in analog mode, the output mode of the pin is determined by the port 1 latch and p1mdout (figure 18.13). see section ?7. 10-bit adc (adc2, c8051f060/1/2/3)? on page 87 for more information about adc2. r/w r/w r/w r/w r/w r/w r/w r/w reset value p1.7 p1.6 p1.5 p1.4 p1.3 p1.2 p1.1 p1.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x90 all pages figure 18.12. p1mdin: port1 input mode register bits7-0: p1mdin.[7:0]: port 1 input mode bits. 0: port pin is configured in analog input mode. th e digital input path is disabled (a read from the port bit will always retu rn ?0?). the weak pull-up on the pin is disabled. 1: port pin is configured in digital input mode. a read from the port bit will return the logic level at the pin. the state of the weak pull- up is determined by the weakpud bit (xbr2.7, see figure 18.7). r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xad f
c8051f060/1/2/3/4/5/6/7 216 rev. 1.2 figure 18.13. p1mdout: port1 output mode register bits7-0: p1mdout.[7:0]: port1 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. note: sda, scl, and rx0 (when uart0 is in mode 0) and rx1 (when uart1 is in mode 0) are always configured as open-drain when they appear on port pins. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa5 f figure 18.14. p2: port2 data register bits7-0: p2.[7:0]: port2 output latch bits. (write - output appears on i/o pins per xbr0, xbr1, xbr2, and xbr3 registers) 0: logic low output. 1: logic high output (open if corresponding p2mdout.n bit = 0). (read - regardless of xbr0, xbr1, xbr2, and xbr3 register settings). 0: p2.n pin is logic low. 1: p2.n pin is logic high. r/w r/w r/w r/w r/w r/w r/w r/w reset value p2.7 p2.6 p2.5 p2.4 p2.3 p2.2 p2.1 p2.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xa0 all pages
c8051f060/1/2/3/4/5/6/7 rev. 1.2 217 figure 18.15. p2mdin: port2 input mode register bits7-0: p2mdin.[7:0]: port 2 input mode bits. 0: port pin is configured in analog input mode. th e digital input path is disabled (a read from the port bit will always retu rn ?0?). the weak pull-up on the pin is disabled. 1: port pin is configured in digital input mode. a read from the port bit will return the logic level at the pin. the state of the weak pull- up is determined by the weakpud bit (xbr2.7, see figure 18.7). r/w r/w r/w r/w r/w r/w r/w r/w reset value 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xae f figure 18.16. p2mdout: port2 output mode register bits7-0: p2mdout.[7:0]: port2 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. note: sda, scl, and rx0 (when uart0 is in mode 0) and rx1 (when uart1 is in mode 0) are always configured as open-drain when they appear on port pins. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa6 f
c8051f060/1/2/3/4/5/6/7 218 rev. 1.2 figure 18.17. p3: port3 data register bits7-0: p3.[7:0]: port3 output latch bits. (write - output appears on i/o pins per xbr0, xbr1, xbr2, and xbr3 registers) 0: logic low output. 1: logic high output (open if corresponding p3mdout.n bit = 0). (read - regardless of xbr0, xbr1, xbr2, and xbr3 register settings). 0: p3.n pin is logic low. 1: p3.n pin is logic high. note: although p3 is not brought out to pins on t he c8051f061/3/5/7 devices, the port data regis- ter is still present and can be used by software . see ?configuring ports which are not pinned out? on page 219. r/w r/w r/w r/w r/w r/w r/w r/w reset value p3.7 p3.6 p3.5 p3.4 p3.3 p3.2 p3.1 p3.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xb0 all pages figure 18.18. p3mdout: port3 output mode register bits7-0: p3mdout.[7:0]: port3 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa7 f
c8051f060/1/2/3/4/5/6/7 rev. 1.2 219 18.2. ports 4 through 7 (c8051f060/2/4/6 only) all port pins on ports 4 through 7 can be accessed as general-purpose i/o (gpio) pins by reading and writing the associated port data registers (s ee figure 18.19, figure 18.21, figure 18.23, and figure 18.25), a set of sfrs which are byte-addressable. note that port 4 has only three pins: p4.5, p4.6, and p4.7. note also that the port 4, 5, 6, and 7 registers are located on sfr page f. the sfrpage reg- ister must be set to 0x0f to access these port registers. a read of a port data register (or port bit) will always return the logic st ate present at the pin itself, regard- less of whether the crossbar has allocated the pin for peripheral use or not. an exception to this occurs during the execution of a read-modify-write instruction (anl, orl, xrl, cpl, inc, dec, djnz, jbc, clr, setb, and the bitwise mov write operation). during the read cycle of the read-modify-write instruc- tion, it is the contents of the port data register, no t the state of the port pins themselves, which is read. 18.2.1. configuring ports which are not pinned out although p3, p4, p5, p6, and p7 are not brought out to pins on the c8051f0 61/3/5/7 devices, the port data registers are still present and can be used by software. because the digital input paths also remain active, it is recommended that these pins not be left in a ?floating? state in order to avoid unnecessary power dissipation arising from the in puts floating to non-valid logic levels. this condition can be prevented by any of the following: 1. leave the weak pull-up de vices enabled by setting w eakpud (xbr2.7) to a logic 0. 2. configure the output modes of p3, p4, p5, p6, and p7 to ?push-pull? by writing 0xff to the associated output mode register (pnmdout). 3. force the output states of p3, p4, p5, p6, and p7 to logic 0 by writin g zeros to the port data registers: p3 = 0x00, p4 = 0x00, p5 = 0x00, p6= 0x00, and p7 = 0x00. 18.2.2. configuring the output modes of the port pins the output mode of each port pin can be configured to be either open-drain or push-pull. in the push-pull configuration, a logic 0 in the asso ciated bit in the port data register will cause the port pin to be driven to gnd, and a logic 1 will cause the port pin to be driven to vdd. in the open-drain configuration, a logic 0 in the associated bit in the po rt data register will cause the port pi n to be driven to gnd, and a logic 1 will cause the port pin to assume a high-impedance state. the open-drain configuration is useful to prevent contention between devices in syst ems where the port pin participates in a shared interconnection in which multiple outputs are connected to the same physical wire. the output modes of the port pins on ports 4 through 7 are determined by the bits in their respective pnm- dout output mode registers. each bit in pnmdout controls the output mode of its corresponding port pin (see figure 18.20, figure 18.22, figure 18.24, and figure 18.26). for example, to place port pin 5.3 in push-pull mode (digital output), se t p5mdout.3 to logic 1. all port pins default to open-drain mode upon device reset. 18.2.3. configuring port pins as digital inputs a port pin is configured as a digital input by setting its output mode to ?open-drain? and writing a logic 1 to the associated bit in the port data register. for exampl e, p7.7 is configured as a digital input by setting p7mdout.7 to a logic 0 and p7.7 to a logic 1. 18.2.4. weak pull-ups by default, each port pin has an internal weak pu ll-up device enabled which pr ovides a resistive connec- tion (about 100 k ? ) between the pin and vdd. the weak pull-up devices can be globally disabled by writ-
c8051f060/1/2/3/4/5/6/7 220 rev. 1.2 ing a logic 1 to the weak pull-up disable bit, (weakpud, xbr2.7). the weak pull-up is automatically deactivated on any pin that is driv ing a logic 0; that is, an output pin will not contend with its own pull-up device. 18.2.5. external memory interface if the external memory interface is enabled on the high ports and an off-chip movx operation occurs, the external memory interface will contro l the output states of the affected port pins during the execution phase of the movx instruction, regard less of the settings of the port da ta registers. the output configura- tion of the port pins is not affected by the emif oper ation, except that read operations will explicitly dis- able the output drivers on the data bus during the movx execution. see section ?17. external data memory interface and on-chip xram? on page 187 for more information about the external memory inter- face.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 221 figure 18.19. p4: port4 data register bits7-5: p4.[7:5]: port4 output latch bits. write - output appears on i/o pins. 0: logic low output. 1: logic high output (open, if corresponding p4mdout.n bit = 0). see figure 18.20. read - returns states of i/o pins. 0: p4.n pin is logic low. 1: p4.n pin is logic high. bits 4-0: reserved. write to ?11111?. note: p4.7 (/wr), p4.6 (/rd), and p4.5 (ale) can be driven by the external data memory interface. see section ?17. external data memory interface and on-chip xram? on page 187 for more information. r/w r/w r/w r/w r/w r/w r/w r/w reset value p4.7 p4.6 p4.5 - - - - - 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xc8 f figure 18.20. p4mdout: port4 output mode register bits7-5: p4mdout.[7:5]: port4 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. bits 4-0: reserved. write to ?00000?. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - - - 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9c f
c8051f060/1/2/3/4/5/6/7 222 rev. 1.2 figure 18.21. p5: port5 data register bits7-0: p5.[7:0]: port5 output latch bits. write - output appears on i/o pins. 0: logic low output. 1: logic high output (open, if corresponding p5mdout bit = 0). see figure 18.22. read - returns states of i/o pins. 0: p5.n pin is logic low. 1: p5.n pin is logic high. note: p5.[7:0] can be driven by the external data memory interface (as address[15:8] in non-mul- tiplexed mode). see section ?17. external data memory interface and on-chip xram? on page 187 for more information about the external memory interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value p5.7 p5.6 p5.5 p5.4 p5.3 p5.2 p5.1 p5.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xd8 f figure 18.22. p5mdout: port5 output mode register bits7-0: p5mdout.[7:0]: port5 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9d f
c8051f060/1/2/3/4/5/6/7 rev. 1.2 223 figure 18.23. p6: port6 data register bits7-0: p6.[7:0]: port6 output latch bits. write - output appears on i/o pins. 0: logic low output. 1: logic high output (open, if corresponding p6mdout bit = 0). see figure 18.24. read - returns states of i/o pins. 0: p6.n pin is logic low. 1: p6.n pin is logic high. note: p6.[7:0] can be driven by the external data memory interf ace (as address[15:8] in multi- plexed mode, or as address[7:0] in non-multiplexed mode). see section ?17. external data memory interface and on-chip xram? on page 187 for more informatio n about the external memory interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value p6.7 p6.6 p6.5 p6.4 p6.3 p6.2 p6.1 p6.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xe8 f figure 18.24. p6mdout: port6 output mode register bits7-0: p6mdout.[7:0]: port6 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9e f
c8051f060/1/2/3/4/5/6/7 224 rev. 1.2 figure 18.25. p7: port7 data register bits7-0: p7.[7:0]: port7 output latch bits. write - output appears on i/o pins. 0: logic low output. 1: logic high output (open, if corresponding p7mdout bit = 0). see figure 18.26. read - returns states of i/o pins. 0: p7.n pin is logic low. 1: p7.n pin is logic high. note: p7.[7:0] can be driven by the external data memory interf ace (as ad[7:0] in multiplexed mode, or as d[7:0] in n on-multiplexed mode). see section ?17. external data memory inter- face and on-chip xram? on page 187 for more information ab out the external memory interface. r/w r/w r/w r/w r/w r/w r/w r/w reset value p7.7 p7.6 p7.5 p7.4 p7.3 p7.2 p7.1 p7.0 11111111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xf8 f figure 18.26. p7mdout: port7 output mode register bits7-0: p7mdout.[7:0]: port7 output mode bits. 0: port pin output mode is configured as open-drain. 1: port pin output mode is configured as push-pull. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9f f
c8051f060/1/2/3/4/5/6/7 rev. 1.2 225 19. controller area networ k (can0, c8051f060/1/2/3) important documentation note: the bosch can controller is integrated in the c8051f060/1/2/3 devices. this section of the data sheet gives a description of the can controller as an overview and offers a description of how the silicon labs cip-51 mcu in terfaces with the on-chip bosch can controller. in order to use the can controller, please refer to bosc h?s c_can user?s manual (revision 1.2) as an accom- panying manual to silicon labs? c8 051f060/1/2/3/4/5/6/7 data sheet. the c8051f060/1/2/3 family of devices feature a co ntrol area network (can) controller that enables serial communication using the can protocol. silicon labs can controller facilit ates communication on a can network in accordance with the bosch specification 2.0a (bas ic can) and 2.0b (full can). the can controller consists of a can core, message ram (separate from the cip-51 ram), a message handler state machine, and co ntrol registers. silicon labs ca n is a protocol controller and does not provide physi- cal layer drivers (i.e., tr ansceivers). figure 19.2 shows an example typical configuration on a can bus. silicon labs can operates at bit rates of up to 1 mb it/second, though this can be limited by the physical layer chosen to transmit data on the can bus. the can processor has 32 message objects that can be configured to transmit or receive data. incoming data, message objects and their identifier masks are stored in the can message ram. all pr otocol functions for tr ansmission of data and acceptance filtering is performed by the can controller and not by the cip-51 mcu. in this way, minimal cpu bandwidth is needed to use can communication. the cip-51 config ures the can controller, accesses received data, and passes data for transmission via special functi on registers (sfr) in the cip-51. the can control- ler?s clock (f sys , or can_clk in the c_can user?s guide) is equal to the cip-51 mcu?s clock (sysclk).
c8051f060/1/2/3/4/5/6/7 226 rev. 1.2 message handler registers message ram (32 message objects) can core tx rx can controller c 8 0 5 1 m c u interrupt s f r 's cantx canrx c8051f060/1/2/3 figure 19.1. can controller diagram c8051f06x cantx canrx can_h can _ l isolation/buffer (optional) can transceiver isolation/buffer (optional) can transceiver isolation/buffer (optional) can transceiver r r can protocol device can protocol device figure 19.2. typical can bus configuration
c8051f060/1/2/3/4/5/6/7 rev. 1.2 227 19.1. bosch can cont roller operation the can controller featured in the c8051f060/1/2/3 devices is a full implementation of bosch?s full can module and fully complies wi th can specification 2.0b. the function and use of the can controller is detailed in the bosch can user?s guide . the user?s guide should be used as a re ference to configure and use the can co ntroller. this silicon labs datasheet describes how to acce ss the can controller. the can control register (can0cn), can test register (can0tst), an d can status register (can0sta) in the can controller can be accessed dire ctly or indirectly via cip-51 sfrs. all other can registers must be accessed via an indirect inde xing method. see ?using can0adr, can0dath, and candatl to access can registers? on page 229.
c8051f060/1/2/3/4/5/6/7 228 rev. 1.2 19.2. can registers can registers are classified as follows: 1. can controller protocol registers : can control, interrupt, error control, bus status, test modes. 2. message object interface registers : used to configure 32 message objects, send and receive data to and from message objects. the c8051 mcu accesses the can message ram via the message object interface registers. upon writing a message object number to an if1 or if2 command request register, the contents of the associated interface registers (if1 or if2) will be transferred to or from the message object in can ram. 3. message handler registers : these read only registers are used to provide information to the cip-51 mcu about the message object s (msgvld flags, transmission request pending, new data flags) and interrupts p ending (which message objects have caused an interrupt or status interrupt condition). 4. c8051 mcu special function registers (sfr) : five registers located in the c8051 mcu memory map that allow direct access to ce rtain can controller protocol registers, and indexed indirect access to all can registers. 19.2.1. can controller protocol registers the can control protocol registers are used to config ure the can controller, process interrupts, monitor bus status, and place the controller in test modes. the can controller protocol registers are accessible using c8051 mcu sfrs by an indexed method, and some can be accessed directly by addressing the sfrs in the c8051 sfr map for convenience. the registers are: can control regi ster (can0cn), can status register (can0sta), can test register (can0tst), error counter register, bit timing regi ster, and the baud rate prescaler (brp) extension register. can0sta, can0cn, and can0tst can be accessed via c8051 mcu sfrs. all others are accessed indirectly using the ca n address indexed method via can0 adr, can0dath, and can0datl. please refer to the bosch can user?s guide for information on the function and use of the can control protocol registers. 19.2.2. message object interface registers there are two sets of message object interface registers used to configure the 32 message objects that transmit and receive data to and from the can bus. message objects can be configured for transmit or receive, and are assigned arbitration message iden tifiers for acceptance f iltering by all can nodes. message objects are stored in message ram, and are accessed and configured using the message object interface registers. these registers are a ccessed via the c8051?s can0adr and can0dat regis- ters using the indirect indexed address method. please refer to the bosch can user?s guide for information on the function and use of the mes- sage object interface registers. 19.2.3. message handler registers the message handler registers are read only registers. their flags can be read via the indexed access method with can0adr, can0dath, and can0datl. the message handler registers provide interrupt, error, transmit/receive requests, and new data information.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 229 please refer to the bosch can user?s guide for information on the function and use of the mes- sage handler registers. 19.2.4. cip-51 mcu special function registers c8051f060/1/2/3 peripherals are modified, monitored, and controlled using special function registers (sfrs). most of the can controlle r registers cannot be accessed directly using the sfrs. three of the can controller?s registers may be accessed directly with sfrs. all other can controller registers are accessed indirectly using three cip-51 mcu sfrs: the can data registers (can0dath and can0datl) and can address register (can0adr). in this way, there are a total of five can registers used to configure and run the can controller. 19.2.5. using can0adr, can0dath, and candatl to access can registers each can controller register has an index number (see table below). the can register address space is 128 words (256 bytes). a can register is a ccessed via the can data registers (can0dath and can0datl) when a can register?s index number is placed into the can address register (can0adr). for example, if the bit timing regi ster is to be configured with a new value, can0adr is loaded with 0x03. the low byte of the desired value is accessed using can0datl and the high byte of the bit timing register is accessed using can0dath. can0datl is bit addressable for convenience. to load the value 0x2304 into the bit timing register: can0adr = 0x03; // load bit timing register?s index (table 18.1) can0dath = 0x23; // move the upper byte into data reg high byte can0datl = 0x04; // move the lower byte into data reg low byte note: can0cn, can0sta, and can0tst may be accessed either by using the index method, or by direct access with the cip-51 mcu sfrs. can0cn is located at sfr locati on 0xf8/sfr page 1 (figure 19.6), can0tst at 0xdb/sfr page 1 (figure 19.7), and can0sta at 0xc0/sfr page 1 (figure 19.8). 19.2.6. can0adr autoincrement feature for ease of programming message objects, can0adr features autoincrementing for the index ranges 0x08 to 0x12 (interface registers 1) and 0x20 to 0x 2a (interface registers 2). when the can0adr regis- ter has an index in these ranges, the can0adr will autoincrement by 1 to point to the next can reg- ister 16-bit word upon a read/write of can0datl . this speeds programming of the frequently programmed interface registers when configuring message objects. note: table below supersedes figure 5 in section 3, ?programmer?s model? of the bosch can user?s guide. table 19.1. can register index and reset values can register index register name reset value notes 0x00 can control register 0x0001 accessible in cip-51 sfr map 0x01 status register 0x0000 accessible in cip-51 sfr map 0x02 error register 0x0000 read only 0x03 bit timing register 0x2301 write enabled by cce bit in can0cn
c8051f060/1/2/3/4/5/6/7 230 rev. 1.2 0x04 interrupt register 0x0000 read only 0x05 test register 0x0000 bit 7 (r x) is determined by can bus 0x06 brp extension register 0x0000 write enabled by test bit in can0cn 0x08 if1 command request 0x0001 can0adr autoincrements in if1 index space (0x08 - 0x12) upon write to can0datl 0x09 if1 command mask 0x0000 can0adr autoincrement upon write to can0datl 0x0a if1 mask 1 0xffff can0adr autoin crement upon write to can0datl 0x0b if1 mask 2 0xffff can0adr autoin crement upon write to can0datl 0x0c if1 arbitration 1 0x0000 can0adr autoincrement upon write to can0datl 0x0d if1 arbitration 2 0x0000 can0adr autoincrement upon write to can0datl 0x0e if1 message control 0x0000 can0adr autoincrement upon write to can0datl 0x0f if1 data a1 0x0000 can0adr autoincrement upon write to can0datl 0x10 if1 data a2 0x0000 can0adr autoincrement upon write to can0datl 0x11 if1 data b1 0x0000 can0adr auto increment upon write to can0datl 0x12 if1 data b2 0x0000 can0adr autoincrement upon write to can0datl 0x20 if2 command request 0x0001 can0adr autoincrements in if1 index space (0x08 - 0x12) upon write to can0datl 0x21 if2 command mask 0x0000 can0adr autoincrement upon write to can0datl 0x22 if2 mask 1 0xffff can0adr autoin crement upon write to can0datl 0x23 if2 mask 2 0xffff can0adr autoin crement upon write to can0datl 0x24 if2 arbitration 1 0x0000 can0adr autoincrement upon write to can0datl 0x25 if2 arbitration 2 0x0000 can0adr autoincrement upon write to can0datl 0x26 if2 message control 0x0000 can0adr autoincrement upon write to can0datl 0x27 if2 data a1 0x0000 can0adr autoincrement upon write to can0datl 0x28 if2 data a2 0x0000 can0adr autoincrement upon write to can0datl 0x29 if2 data b1 0x0000 can0adr autoincrement upon write to can0datl 0x2a if2 data b2 0x0000 can0adr auto increment upon write to can0datl 0x40 transmission request 1 0x0000 transmiss ion request flags for message objects (read only) 0x41 transmission request 2 0x0000 transmiss ion request flags for message objects (read only) 0x48 new data 1 0x0000 new data flags for message objects (read only) 0x49 new data 2 0x0000 new data flags for message objects (read only) 0x50 interrupt pending 1 0x0000 interrupt pending flags for message objects (read only) 0x51 interrupt pending 2 0x0000 interrupt pending flags for message objects (read only) 0x58 message valid 1 0x0000 message valid flags for message objects (read only) table 19.1. can register index and reset values (continued) can register index register name reset value notes
c8051f060/1/2/3/4/5/6/7 rev. 1.2 231 0x59 message valid 2 0x0000 message valid flags for message objects (read only) table 19.1. can register index and reset values (continued) can register index register name reset value notes figure 19.3. can0dath: can data access register high byte bit7-0: can0dath: can data access register high byte. the can0dat registers are used to read/write register values and data to and from the can registers pointed to with the index number in the can0adr register. the can0adr register is used to point th e [can0dath:can0datl] to a desired can register. the desired can register?s inde x number is moved into can0adr. the can0dat register can then read/write to and from the can register. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd9 1 figure 19.4. can0datl: can data access register low byte bit7-0: can0datl: can data access register low byte. the can0dat registers are used to read/write register values and data to and from the can registers pointed to with the index number in the can0adr register. the can0adr register is used to point th e [can0dath:can0datl] to a desired can register. the desired can register?s inde x number is moved into can0adr. the can0dat register can then read/write to and from the can register. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000001 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd8 1
c8051f060/1/2/3/4/5/6/7 232 rev. 1.2 figure 19.5. can0adr: can address index register bit7-0: can0adr: can address index register. the can0adr register is used to point th e [can0dath:can0datl] to a desired can register. the desired can register?s inde x number is moved into can0adr. the can0dat register can then read/write to and from the can register. note : when the value of can0adr is 0x08-0x12 and 0x20-2a (if1 and if2 registers), this register will autoincr ement by 1 upon a write to can0datl. see section ?19.2.6. can0adr autoincrement feature? on page 229 . all can registers? functions/definitions ar e listed and described in the bosch can user?s guide. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xda 1 figure 19.6. can0cn: can control register bit 4: canif: can interrupt flag. write = don?t care. 0: can interrupt has not occured. 1: can interrupt has occured and is active. canif is controlled by the can controller and is cleared by hardware once all interrupt con- ditions have been cleared in the can controller. see section 3.4.1 in the bosch can user?s guide (page 24) for more information concerning can controller interrupts. *all can registers? functions/definitions are listed and described in the bosch can user?s guide with the exception of the canif bit. this register may be accessed directly in the cip-51 sfr register space, or through the indi- rect, index method (see section ? 19.2.5. using can0adr, can0dath, and candatl to access can registers ? on page 229 ). r/w r/w r/w r r/w r/w r/w r/w reset value ***canif*** * bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xf8 1
c8051f060/1/2/3/4/5/6/7 rev. 1.2 233 figure 19.7. can0tst: can test register all can registers? functions/definitions ar e listed and described in the bosch can user?s guide. this register may be accessed directly in the cip-51 sfr register space, or through the indi- rect, index method (see section ? 19.2.5. using can0adr, can0dath, and candatl to access can registers ? on page 229 ). r/w r/w r/w r/w r/w r/w r/w r/w reset value please see the bosch can user?s guide for a complete definition of this register bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xdb 1 figure 19.8. can0sta: can status register all can registers? functions/definitions ar e listed and described in the bosch can user?s guide. this register may be accessed directly in the cip-51 sfr register space, or through the indi- rect, index method (see section ? 19.2.5. using can0adr, can0dath, and candatl to access can registers ? on page 229 ). r/w r/w r/w r/w r/w r/w r/w r/w reset value please see the bosch can user?s guide for a complete definition of this register bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc0 1
c8051f060/1/2/3/4/5/6/7 234 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 235 20. system management bus / i2c bus (smbus0) the smbus0 i/o interface is a two-wire, bi-direction al serial bus. smbus0 is compliant with the system management bus specification, version 1.1, and compat ible with the i2c serial bus. reads and writes to the interface by the system controller are byte ori ented with the smbus0 interface autonomously control- ling the serial transfer of the data. a method of ext ending the clock-low duration is available to accommo- date devices with different spe ed capabilities on the same bus. smbus0 may operate as a master and/or slave, and may function on a bus with multiple masters. smbus0 provides control of sda (serial data), scl (serial cl ock) generation and synchron ization, arbitration logic, and start/stop control and generation. figure 20.1. smbus0 block diagram sfr bus data path control sfr bus write to smb0dat smbus control logic read smb0dat smb0adr s l v 6 g c s l v 5 s l v 4 s l v 3 s l v 2 s l v 1 s l v 0 c r o s s b a r clock divide logic sysclk smb0cr c r 7 c r 6 c r 5 c r 4 c r 3 c r 2 c r 1 c r 0 scl filter n sda control 0000000b 7 msbs 8 a b a=b 8 0 1 2 3 4 5 6 7 smb0dat 8 smb0cn s t a s i a a f t e t o e e n s m b b u s y s t o smb0sta s t a 4 s t a 3 s t a 2 s t a 1 s t a 0 scl control status generation arbitration scl synchronization scl generation (master mode) irq generation s t a 5 s t a 6 s t a 7 a b a=b smbus irq interrupt request port i/o 1 0 sda filter n 7
c8051f060/1/2/3/4/5/6/7 236 rev. 1.2 figure 20.2 shows a typical smbus configuration. the smbu s0 interface will work at any voltage between 3.0 v and 5.0 v and different devices on the bus may op erate at different voltage levels. the bi-directional scl (serial clock) and sda (serial data) lines must be connected to a positive power supply voltage through a pull-up resistor or similar circuit. every dev ice connected to the bus must have an open-drain or open-collector output for both the scl and sda lines, so that both are pulled high when the bus is free. the maximum number of devices on the bus is limited only by the requirement that the rise and fall times on the bus will not exceed 300 ns and 1000 ns, respectively. 20.1. supporting documents it is assumed the reader is fam iliar with or has access to th e following supporting documents: 1. the i2c-bus and how to use it (includi ng specifications), philips semiconductor. 2. the i2c-bus specification -- ve rsion 2.0, philips semiconductor. 3. system management bus specification -- version 1.1, sbs implementers forum. 20.2. smbus protocol two types of data transfers are possible: data transfers from a master transmitter to an addressed slave receiver (write), and data transfers from an addres sed slave transmitter to a master receiver (read). the master device initiates both types of data transfer s and provides the serial clock pulses on scl. note: multiple master devices on the same bus are supported. if two or more masters attempt to initiate a data transfer simultaneously, an arbitration scheme is empl oyed with a single master always winning the arbitra- tion. note that it is not necessary to specify one device as the master in a system; any device who trans- mits a start and a slave address beco mes the master for that transfer. a typical smbus transaction consists of a start cond ition followed by an address byte (bits7-1: 7-bit slave address; bit0: r/w direction bit), one or more byte s of data, and a stop condition. each byte that is received (by a master or slave) must be acknow ledged (ack) with a low sda during a high scl (see figure 20.3). if the receiving devic e does not ack, the tr ansmitting device will read a ?not acknowledge? (nack), which is a high sda during a high scl. figure 20.2. typical smbus configuration vdd = 5v master device slave device 1 slave device 2 vdd = 3v vdd = 5v vdd = 3v sda scl
c8051f060/1/2/3/4/5/6/7 rev. 1.2 237 the direction bit (r/w) occupies the least-significant bi t position of the address. the direction bit is set to logic 1 to indicate a "read" operation and clear ed to logic 0 to indicate a "write" operation. all transactions are initiated by a master, with one or more addressed slave devices as the target. the master generates the start condition and then transmit s the slave address and dire ction bit. if the trans- action is a write operation from th e master to the slave, the master transmits the data a byte at a time waiting for an ack from the slave at the end of each byte. for read operations , the slave transmits the data waiting for an ack from the master at the end of each byte. at the end of the data transfer, the master generates a stop condition to term inate the transaction and free the bu s. figure 20.3 illustrates a typical smbus transaction. 20.2.1. arbitration a master may start a transfer only if the bus is free. th e bus is free after a stop condition or after the scl and sda lines remain high for a specified time (see section 20.2.4 ). in the event that two or more devices attempt to begin a transfer at the same time, an arbi tration scheme is employed to force one master to give up the bus. the master devices continue transmitting until one attempts a high while the other transmits a low. since the bus is open- drain, the bus will be pulled low. the master attempting the high will detect a low sda and give up the bus. the winning master continues its transmission without interruption; the losing master becomes a slave and receives the rest of the transfer. this arbitration scheme is non- destructive: one device always wins, and no data is lost. 20.2.2. clock low extension smbus provides a clock synchronizati on mechanism, similar to i2c, wh ich allows devices with different speed capabilities to coexist on the bus. a clock-low extension is used du ring a transfer in order to allow slower slave devices to communica te with faster masters. the slave may temporarily hold the scl line low to extend the clock low period, effectively decreasing the serial clock frequency. 20.2.3. scl low timeout if the scl line is held low by a slave device on the bus, no further communication is possible. furthermore, the master cannot force the scl line high to correct th e error condition. to solve this problem, the smbus protocol specifies that devices participating in a tran sfer must detect any clock cycle held low longer than 25 ms as a ?timeout? condition. devices that have det ected the timeout condition must reset the communi- cation no later than 10 ms after detecting the timeout condition. 20.2.4. scl high (smbus free) timeout the smbus specification stipulates th at if the scl and sda lines remain high for more that 50 s, the bus is designated as free. if an smbus device is waiting to generat e a master start, the start will be gen- erated following the bus free timeout. sla6 sda sla5-0 r/w d7 d6-0 scl slave address + r/w data byte start ack nack stop figure 20.3. smbus transaction
c8051f060/1/2/3/4/5/6/7 238 rev. 1.2 20.3. smbus transfer modes the smbus0 interface may be configured to operate as a master and/or a slave. at any particular time, the interface will be operating in one of the following modes: master transmitter, master receiver, slave transmitter, or slave receiver. see table 20.1 for transfer mode status decoding using the smb0sta sta- tus register. the following mode de scriptions illustrate an interrupt- driven smbus0 app lication; smbus0 may alternatively be operated in polled mode. 20.3.1. master transmitter mode serial data is transmitted on sda while the serial clock is output on scl. smbus0 generates a start condition and then transmits the first byte containing the address of the target slave device and the data direction bit. in this case the data direction bit (r/w) will be logic 0 to indicate a "write" operation. the smbus0 interface transmits one or more bytes of seri al data, waiting for an acknowledge (ack) from the slave after each byte. to indicate the end of the serial transfer, smbus0 generates a stop condition. 20.3.2. master receiver mode serial data is received on sda while the serial cloc k is output on scl. the smbus0 interface generates a start followed by the first data byte containing the ad dress of the target slave and the data direction bit. in this case the data direction bit (r/w) will be logi c 1 to indicate a "read" ope ration. the smbus0 inter- face receives serial data from the slave and generates the clock on scl. after each byte is received, smbus0 generates an ack or nack depending on t he state of the aa bit in register smb0cn. smbus0 generates a stop condition to indicate the end of the serial transfer. a a a s w p data byte data byte sla s = start p = stop a = ack w = write sla = slave address received by smbus interface transmitted by smbus interface interrupt interrupt interrupt interrupt figure 20.4. typical master transmitter sequence data byte data byte a n a s r p sla s = start p = stop a = ack n = nack r = read sla = slave address received by smbus interface transmitted by smbus interface interrupt interrupt interrupt interrupt figure 20.5. typical master receiver sequence
c8051f060/1/2/3/4/5/6/7 rev. 1.2 239 20.3.3. slave transmitter mode serial data is transmitted on sda while the serial clo ck is received on scl. th e smbus0 interface receives a start followed by data byte containing the slave addr ess and direction bit. if the received slave address matches the address held in regi ster smb0adr, the sm bus0 interface generate s an ack. smbus0 will also ack if the general call address (0x00) is received and the general call address enable bit (smb0adr.0) is set to logic 1. in th is case the data direction bit (r/w) will be logic 1 to indicate a "read" operation. the smbus0 interface receives the clock on scl and transmits one or more bytes of serial data, waiting for an ack from the master after each byte. smbus0 exits slave mode after receiving a stop condition from the master. 20.3.4. slave receiver mode serial data is received on sda while the serial clock is received on scl. the smbus0 interface receives a start followed by data byte containing the slave addr ess and direction bit. if the received slave address matches the address held in regist er smb0adr, the interface generates an ack. smbus0 will also ack if the general call address (0x00) is received and the g eneral call address enable bit (smb0adr.0) is set to logic 1. in this case the data direction bit (r/w) will be logic 0 to indicate a "write" operation. the smbus0 interface receives one or more bytes of seri al data; after each byte is received, the interface p r sla s data byte data byte a n a s = start p = stop n = nack r = read sla = slave address received by smbus interface transmitted by smbus interface interrupt interrupt interrupt interrupt figure 20.6. typical slave transmitter sequence
c8051f060/1/2/3/4/5/6/7 240 rev. 1.2 transmits an ack or nack depending on the state of the aa bit in smb0cn. smbus0 exits slave receiver mode after receiving a stop condition from the master. p w sla s data byte data byte a a a s = start p = stop a = ack w = write sla = slave address received by smbus interface transmitted by smbus interface interrupt interrupt interrupt interrupt figure 20.7. typical slave receiver sequence
c8051f060/1/2/3/4/5/6/7 rev. 1.2 241 20.4. smbus special function registers the smbus0 serial interface is accessed and cont rolled through five sfrs: smb0cn control register, smb0cr clock rate register, smb0adr address regi ster, smb0dat data register and smb0sta sta- tus register. the five special function registers related to the operation of the smbus0 interface are described in the following sections. 20.4.1. control register the smbus0 control register smb0cn is used to conf igure and control the smbus0 interface. all of the bits in the register can be read or written by software. two of the control bits are also affected by the smbus0 hardware. the serial interrupt flag (si, smb0cn. 3) is set to logic 1 by the hardware when a valid serial interrupt condition occurs. it can only be cleared by software. the stop flag (sto, smb0cn.4) is set to logic 1 by software. it is cleared to logic 0 by hardware when a stop condition is detected on the bus. setting the ensmb flag to logic 1 enables the smbus0 interface. clearing the ensmb flag to logic 0 dis- ables the smbus0 interface and removes it from the bus. momentarily clearing the ensmb flag and then resetting it to logic 1 will reset smbu s0 communication. however, ensm b should not be used to tempo- rarily remove a device from the bus since the bus state information will be lo st. instead, the assert acknowledge (aa) flag should be used to temporarily remove the device from the bus (see description of aa flag below). setting the start flag (sta, smb0cn.5) to logic 1 will put smbus0 in a master mode. if the bus is free, smbus0 will generate a start conditi on. if the bus is not free, smbus0 waits for a stop condition to free the bus and then generates a start condition after a 5 s delay per the smb0cr value (in accordance with the smbus protocol, the smbus0 interface also considers the bus free if the bus is idle for 50 s and no stop condition was recognized). if sta is set to logic 1 while smbus0 is in master mode and one or more bytes have bee n transferred, a re peated start conditio n will be generated. when the stop flag (sto, smb0cn.4) is set to logic 1 while the smbus0 interfac e is in master mode, the interface generates a stop condition. in a slave mode, the sto flag may be used to recover from an error condition. in this case, a stop condition is not generated on the bus, but the smbus hardware behaves as if a stop condition has been received and enters the "not addressed" slave receiver mode. note that this simulated stop will not cause the bus to appear fr ee to smbus0. the bus will remain occupied until a stop appears on the bus or a bus free timeout occurs. hardware automatically clears the sto flag to logic 0 when a stop condition is detected on the bus. the serial interrupt flag (si, smb0cn.3) is set to logic 1 by hard ware when the smbu s0 interface enters one of 27 possible states. if interrupts are enabled fo r the smbus0 interface, an interrupt request is gener- ated when the si flag is set. the si flag must be cleared by software. important note: if si is set to logic 1 while the scl line is low, the clock-low period of the serial clock will be stretched and the serial transfer is suspended until si is cleared to logic 0. a high level on scl is not affected by the setting of the si flag. the assert acknowledge flag (aa, smb0cn.2) is used to set the level of the sda line during the acknowl- edge clock cycle on the scl line. se tting the aa flag to logic 1 will caus e an ack (low level on sda) to be sent during the acknowledge cycle if the device has been addressed. setting the aa flag to logic 0 will cause a nack (high level on sda) to be sent during acknowledge cycle. after the transmission of a byte in slave mode, the slave can be temporarily removed from the bus by clearing the aa flag. the slave's own address and general ca ll address will be ignored. to resume operation on the bus, the aa flag must be reset to logic 1 to allow the slave's address to be recognized.
c8051f060/1/2/3/4/5/6/7 242 rev. 1.2 setting the smbus0 free timer enable bit (fte, smb0cn.1) to logic 1 enables the timer in smb0cr. when scl goes high, the timer in smb0cr counts up. a timer overflow indica tes a free bus timeout: if smbus0 is waiting to generate a start, it will do so after this timeout. the bus free period should be less than 50 s (see figure 20.9, smbus0 clock rate register). when the toe bit in smb0cn is set to logic 1, time r 4 is used to detect scl low timeouts. if timer 4 is enabled (see section ?24.2. timer 2, timer 3, and timer 4? on page 295 ), timer 4 is forced to reload when scl is high, and forced to count when scl is low. wi th timer 4 enabled and configured to overflow after
c8051f060/1/2/3/4/5/6/7 rev. 1.2 243 25 ms (and toe set), a timer 4 overflow indicates a sc l low timeout; the timer 4 interrupt service routine can then be used to reset smbus0 communication in the event of an scl low timeout. figure 20.8. smb0cn: smbus0 control register bit7: busy: busy status flag. 0: smbus0 is free. 1: smbus0 is busy. bit6: ensmb: smbus enable. this bit enables/disables the smbus serial interface. 0: smbus0 disabled. 1: smbus0 enabled. bit5: sta: smbus start flag. 0: no start condition is transmitted. 1: when operating as a master, a start conditi on is transmitted if the bus is free. (if the bus is not free, the start is transmitted after a stop is received.) if sta is set after one or more bytes have been transmitted or received and before a stop is received, a repeated start condition is transmitted. bit4: sto: smbus stop flag. 0: no stop condition is transmitted. 1: setting sto to logic 1 causes a stop conditi on to be transmitted. when a stop condi- tion is received, hardware clears sto to logi c 0. if both sta and sto are set, a stop con- dition is transmitted followed by a start co ndition. in slave mode, setting the sto flag causes smbus to behave as if a stop condition was received. bit3: si: smbus seri al interrupt flag. this bit is set by hardware when one of 27 po ssible smbus0 states is entered. (status code 0xf8 does not cause si to be set.) when the si interrupt is enabled, se tting this bit causes the cpu to vector to the smbu s interrupt service routine. th is bit is not automatically cleared by hardware and must be cleared by software. bit2: aa: smbus assert acknowledge flag. this bit defines the type of acknowledge retu rned during the acknowledge cycle on the scl line. 0: a "not acknowledge" (high level on sda) is returned during the acknowledge cycle. 1: an "acknowledge" (low level on sda) is returned during the acknowledge cycle. bit1: fte: smbus free timer enable bit. 0: no timeout when scl is high. 1: timeout when scl high time exceeds limit specified by the smb0cr value. bit0: toe: smbus timeout enable bit. 0: no timeout when scl is low. 1: timeout when scl low time exceeds limit specified by timer 4, if enabled. r r/w r/w r/w r/w r/w r/w r/w reset value busy ensmb sta sto si aa fte toe 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xc0 0
c8051f060/1/2/3/4/5/6/7 244 rev. 1.2 20.4.2. clock rate register figure 20.9. smb0cr: smbus0 clock rate register bits7-0: smb0cr.[7:0]: smbu s0 clock rate preset. the smb0cr clock rate register controls the frequency of the serial clock scl in master mode. the 8-bit word stored in the smb0cr r egister preloads a dedicated 8-bit timer. the timer counts up, and when it rolls over to 0x00, the scl logic state toggles. the smb0cr setting should be bounded by the following equation , where smb0cr is the unsigned 8-bit value in register smb0cr, and sysclk is the system clock frequency in hz: the resulting scl signal high and low times are given by the following equations: using the same value of smb0cr from above, the bus free timeout period is given in the following equation: r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xcf 0 smb 0 cr 288 ( ( 0.85 ? sysclk ) 1.125 10 6 ? ()) ? ? < t low 256 smb 0 cr ? () sysclk ? = t high 258 smb 0 cr ? () sysclk ? 625 ns + ? t bft 10 256 smb 0 cr ? () 1 + sysclk ------------------- ----------------- ---------------- - ?
c8051f060/1/2/3/4/5/6/7 rev. 1.2 245 20.4.3. data register the smbus0 data register smb0dat holds a byte of serial data to be transmitted or one that has just been received. software can read or write to this regist er while the si flag is set to logic 1; software should not attempt to access the smb0dat register when t he smbus is enabled and the si flag reads logic 0 since the hardware may be in the process of shifting a byte of data in or out of the register. data in smb0dat is always shifted ou t msb first. after a byte has been received, the first bit of received data is located at the msb of smb0dat. while data is being shifted out, data on the bus is simultaneously being shifted in. therefore, smb0dat always contains t he last data byte present on the bus. in the event of lost arbitration, the transition from master transmitter to slave receiver is made with the correct data in smb0dat. 20.4.4. address register the smb0adr address register holds the slave addre ss for the smbus0 interface. in slave mode, the seven most-significant bits hold the 7-bit slave address. the least significant bit (bit0) is used to enable the recognition of the gene ral call address (0x00). if bit0 is set to logic 1, the ge neral call address will be recog- figure 20.10. smb0dat: smbus0 data register bits7-0: smb0dat: smbus0 data. the smb0dat register contains a byte of data to be transmitted on the smbus0 serial inter- face or a byte that has just been received on the smbus0 serial interface. the cpu can read from or write to this register whenever t he si serial interrupt flag (smb0cn.3) is set to logic 1. when the si flag is not set, the syste m may be in the process of shifting data and the cpu should not at tempt to access this register. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc2 0
c8051f060/1/2/3/4/5/6/7 246 rev. 1.2 nized. otherwise, the general call address is ignor ed. the contents of this register are ignored when smbus0 is operating in master mode. 20.4.5. status register the smb0sta status register holds an 8-bit status c ode indicating the current state of the smbus0 inter- face. there are 28 possible smbus0 states, each wit h a corresponding unique status code. the five most significant bits of the status code vary while the three least-significant bits of a valid status code are fixed at zero when si = ?1?. therefore, all po ssible status codes are multiples of eight. this facilitates the use of sta- tus codes in software as an index used to branch to appropriate service routines (allowing 8 bytes of code to service the state or jump to a more extensive service routine). figure 20.11. smb0adr: smbus0 address register bits7-1: slv6-slv0: smbus0 slave address. these bits are loaded with the 7-bit slave address to which smbus0 will respond when oper- ating as a slave transmitter or slave receiver. sl v6 is the most significant bit of the address and corresponds to the first bit of the address byte received. bit0: gc: general call address enable. this bit is used to enable general call address (0x00) recognition. 0: general call address is ignored. 1: general call address is recognized. r/w r/w r/w r/w r/w r/w r/w r/w reset value slv6 slv5 slv4 slv3 slv2 slv1 slv0 gc 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc3 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 247 for the purposes of user software, the contents of the smb0sta register is only defined when the si flag is logic 1. software should never write to the smb0sta register; doing so will yield indeterm inate results. the 28 smbus0 states, along with their correspondi ng status codes, are given in table 1.1. figure 20.12. smb0sta: smbus0 status register bits7-3: sta7-sta3: smbus0 status code. these bits contain the smbus0 status code. th ere are 28 possible status codes; each sta- tus code corresponds to a single smbus state. a valid status code is present in smb0sta when the si flag (smb0cn.3) is set to logic 1. the content of smb0sta is not defined when the si flag is logic 0. writing to the smb0st a register at any time will yield indeterminate results. bits2-0: sta2-sta0: the three least significant bi ts of smb0sta are always read as logic 0 when the si flag is logic 1. r/w r/w r/w r/w r/w r/w r/w r/w reset value sta7 sta6 sta5 sta4 sta3 sta2 sta1 sta0 11111000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xc1 0
c8051f060/1/2/3/4/5/6/7 248 rev. 1.2 table 20.1. smb0sta status codes and states mode status code smbus state typical action mt/ mr 0x08 start condition transmitted. load smb0dat with slave address + r/w. clear sta. 0x10 repeated start condition transmitted. load smb0dat with slave address + r/w. clear sta. master transmitter 0x18 slave address + w transmitted. ack received. load smb0dat with data to be transmit- ted. 0x20 slave address + w transmitted. nack received. acknowledge poll to retry. set sto + sta. 0x28 data byte transmitted. ack received. 1) load smb0dat with next byte, or 2) set sto, or 3) clear sto then set sta for repeated start. 0x30 data byte transmitted. nack received. 1) retry transfer or 2) set sto. 0x38 arbitration lost. save current data. master receiver 0x40 slave address + r transmitted. ack received. if only receiving one byte, clear aa (send nack after received byte). wait for received data. 0x48 slave address + r transmitted. nack received. acknowledge poll to retry. set sto + sta. 0x50 data byte received. ack transmitted. read smb0dat. wait for next byte. if next byte is last byte, clear aa. 0x58 data byte received. nack transmitted. set sto.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 249 slave receiver 0x60 own slave address + w received. ack trans- mitted. wait for data. 0x68 arbitration lost in sending sla + r/w as mas- ter. own address + w received. ack transmit- ted. save current data for retry when bus is free. wait for data. 0x70 general call address received. ack transmit- ted. wait for data. 0x78 arbitration lost in sending sla + r/w as mas- ter. general call address received. ack trans- mitted. save current data for retry when bus is free. 0x80 data byte received. ack transmitted. read smb0dat. wait for next byte or stop. 0x88 data byte received. nack transmitted. set sto to reset smbus. 0x90 data byte received after general call address. ack transmitted. read smb0dat. wait for next byte or stop. 0x98 data byte received after general call address. nack transmitted. set sto to reset smbus. 0xa0 stop or repeated start received. no action necessary. slave transmitter 0xa8 own address + r received. ack transmitted. load smb0dat with data to transmit. 0xb0 arbitration lost in transmitting sla + r/w as master. own address + r received. ack transmitted. save current data for retry when bus is free. load smb0dat with data to trans- mit. 0xb8 data byte transmitted. ack received. load smb0dat with data to transmit. 0xc0 data byte transmitted. nack received. wait for stop. 0xc8 last data byte transmitted (aa=0). ack received. set sto to reset smbus. slave 0xd0 scl clock high timer per smb0cr timed out set sto to reset smbus. all 0x00 bus error (illegal start or stop) set sto to reset smbus. 0xf8 idle state does not set si. table 20.1. smb0sta status codes and states mode status code smbus state typical action
c8051f060/1/2/3/4/5/6/7 250 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 251 21. enhanced serial peri pheral interface (spi0) the enhanced serial peripheral interface (spi0) pr ovides access to a flexible, full-duplex synchronous serial bus. spi0 can operate as a master or slave device in both 3-wire or 4-wire modes, and supports mul- tiple masters and slaves on a single spi bus. the slave-select (nss) signal can be configured as an input to select spi0 in slave mode, or to disable master mode operation in a multi-master environment, avoiding contention on the spi bus when more than one master attempts simultaneous data transfers. nss can also be configured as a chip-select output in master mode, or disabled for 3-wire operation. additional gen- eral purpose port i/o pins can be used to se lect multiple slave dev ices in master mode. figure 21.1. spi block diagram sfr bus data path control sfr bus write spi0dat receive data buffer spi0dat 0 1 2 3 4 5 6 7 shift register spi control logic spi0ckr scr7 scr6 scr5 scr4 scr3 scr2 scr1 scr0 spi0cfg spi0cn pin interface control pin control logic c r o s s b a r port i/o read spi0dat spi irq tx data rx data sck mosi miso nss transmit data buffer clock divide logic sysclk ckpha ckpol slvsel nssmd1 nssmd0 spibsy msten nssin srmt rxbmt spif wcol modf rxovrn txbmt spien
c8051f060/1/2/3/4/5/6/7 252 rev. 1.2 21.1. signal descriptions the four signals used by spi0 (mosi, miso, sck, nss) are described below. 21.1.1. master out, slave in (mosi) the master-out, slave-in (mosi) signal is an output fr om a master device and an input to slave devices. it is used to serially transfer data from the master to th e slave. this signal is an output when spi0 is operat- ing as a master and an input when spi0 is operating as a slave. data is transferred most-significant bit first. when configured as a master, mosi is driven by the msb of the shift register in both 3- and 4-wire mode. 21.1.2. master in, slave out (miso) the master-in, slave-out (miso) signal is an output fr om a slave device and an input to the master device. it is used to serially transfer data from the slave to the master. this signal is an input when spi0 is operat- ing as a master and an output when spi0 is operating as a slave. data is transferred most-significant bit first. the miso pin is placed in a high-impedance st ate when the spi module is disabled and when the spi operates in 4-wire mode as a slave that is not select ed. when acting as a slave in 3-wire mode, miso is always driven by the msb of the shift register. 21.1.3. serial clock (sck) the serial clock (sck) signal is an output from the ma ster device and an input to slave devices. it is used to synchronize the transfer of data between the mast er and slave on the mosi and miso lines. spi0 gen- erates this signal when operating as a master. the sck signal is ignored by a spi slave when the slave is not selected (nss = 1) in 4-wire slave mode. 21.1.4. slave select (nss) the function of the slave-select (nss) signal is dependent on the setting of the nssmd1 and nssmd0 bits in the spi0cn register. there are three possib le modes that can be selected with these bits: 1. nssmd[1:0] = 00: 3-wire master or 3-wire slave mode: spi0 operates in 3-wire mode, and nss is disabled. when operating as a slave de vice, spi0 is always sele cted in 3-wire mode. since no select signal is present, spi0 must be the only slave on the bus in 3-wire mode. this is intended for point-to-point communication between a master and one slave. 2. nssmd[1:0] = 01: 4-wire slave or multi-ma ster mode: spi0 operates in 4-wire mode, and nss is enabled as an input. when operating as a slave, nss selects the spi0 device. when operating as a master, a 1-to-0 transition of the nss signal disables the master function of spi0 so that multiple master device s can be used on the same spi bus. 3. nssmd[1:0] = 1x: 4-wire master mode: spi0 o perates in 4-wire mode, and nss is enabled as an output. the setting of nssmd0 determines what logic level the nss pin will output. this configuration should only be used when operating spi0 as a master device. see figure 21.2, figure 21.3, and figure 21.4 for typica l connection diagrams of the various operational modes. note that the setting of nssmd bits affects the pinout of the device. when in 3-wire master or 3-wire slave mode, the nss pin will not be mapped by the crossbar. in all other modes, the nss signal will be mapped to a pin on the device. see section ? 18. port input/output ? on page 203 for general purpose port i/o and crossbar information.
c8051f060/1/2/3/4/5/6/7 rev. 1.2 253 21.2. spi0 master mode operation a spi master device initiates all data transfers on a spi bus. spi0 is placed in master mode by setting the master enable flag (msten, spi0cn.6). writing a byte of data to the spi0 data register (spi0dat) when in master mode writes to the transmit buffer. if the spi shift register is empty, the byte in the transmit buffer is moved to the shift register, and a data transfer begins. the spi0 master immediately shifts out the data serially on the mosi line while provid ing the serial clock on sck. the spi f (spi0cn.7) flag is set to logic 1 at the end of the transfer. if interrupts are enabl ed, an interrupt request is generated when the spif flag is set. while the spi0 master transf ers data to a slave on the mosi line, the addressed spi slave device simultaneously transfers the contents of its shift register to the spi master on the miso line in a full-duplex operation. therefore, the spif flag serves as both a transmit-complete and receive-data-ready flag. the data byte received from the slave is transferred msb- first into the master's shift register. when a byte is fully shifted into the register, it is moved to the re ceive buffer where it can be read by the processor by reading spi0dat. when configured as a master, spi0 can operate in one of three different modes: multi-master mode, 3-wire single-master mode, and 4-wire single-master mode. the default, multi-master mode is active when nssmd1 (spi0cn.3) = 0 and nssmd0 (spi0cn.2) = 1. in this mode, nss is an input to the device, and is used to disable the master spi0 when another ma ster is accessing the bus. when nss is pulled low in this mode, msten (spi0cn.6) and spien (spi0cn.0) ar e set to 0 to disable the spi master device, and a mode fault is generate d (modf, spi0cn.5 = 1). mode fault will gen erate an inte rrupt if enabled. spi0 must be manually re-enabled in soft ware under these circumstances. in multi-master systems, devices will typically default to being slave devices while they are not acting as the system master device. in multi-mas- ter mode, slave devices can be addressed individua lly (if needed) using general-purpose i/o pins. figure 21.2 shows a connection diagram between two master devices in multiple-mas ter mode. 3-wire single-master mode is active when nssmd1 (s pi0cn.3) = 0 and nssmd0 (spi0cn.2) = 0. in this mode, nss is not used, and is not mapped to an exte rnal port pin through the crossbar. any slave devices that must be addressed in this mode should be selected using general-purpose i/o pins. figure 21.3 shows a connection diagram between a master dev ice in 3-wire master mode and a slave device. 4-wire single-master mode is active wh en nssmd1 (spi0cn.3) = 1. in th is mode, nss is configured as an output pin, and can be used as a sl ave-select signal for a single spi dev ice. in this mode, the output value of nss is controlled (in software) with the bit n ssmd0 (spi0cn.2). additional slave devices can be addressed using general-purpose i/o pins. figure 21.4 shows a connection diagram for a master device in 4-wire master mode and two slave devices.
c8051f060/1/2/3/4/5/6/7 254 rev. 1.2 master device 2 master device 1 mosi miso sck miso mosi sck nss gpio nss gpio figure 21.2. multiple-master mode connection diagram figure 21.3. 3-wire single master and 3-wire single slave mode connection diagram slave device master device mosi miso sck miso mosi sck slave device master device mosi miso sck miso mosi sck nss nss gpio slave device mosi miso sck nss figure 21.4. 4-wire single master mode a nd 4-wire slave mode connection diagram
c8051f060/1/2/3/4/5/6/7 rev. 1.2 255 21.3. spi0 slave mode operation when spi0 is enabled and not confi gured as a master, it will operate as a spi slave. as a slave, bytes are shifted in through the mosi pin a nd out through the miso pin by a ma ster device controlling the sck sig- nal. a bit counter in the spi0 logic counts sck edges . when 8 bits have been shifted through the shift reg- ister, the spif flag is set to logic 1, and the byte is copied into the receive buffer. data is read from the receive buffer by reading spi0dat. a slave device cannot initiate transfers. data to be transferred to the master device is pre-loaded into the shift register by writing to spi0dat. writes to spi0dat are double- buffered, and are placed in the transmit buffer first. if the shift register is empty, the contents of the transmit buffer will immediately be transferred into the shift register. when the sh ift register already contains data, the spi will load the shift register wi th the transmit buffer?s contents af ter the last sck edg e of the next (or current) spi transfer. when configured as a slave, spi0 can be configured for 4-wire or 3-wire operation. the default, 4-wire slave mode, is active when nssmd1 (spi0cn.3) = 0 and nssmd0 (spi0cn.2) = 1. in 4-wire mode, the nss signal is routed to a port pin and configured as a digital input. spi0 is enabled when nss is logic 0, and disabled when nss is logic 1. the bit counter is reset on a falling edge of n ss. note that the nss sig- nal must be driven low at least 2 system clocks before the first active edge of sck for each byte transfer. figure 21.4 shows a connection diagram between tw o slave devices in 4-wire slave mode and a master device. 3-wire slave mode is active when nssmd1 (spi0cn. 3) = 0 and nssmd0 (spi0cn.2) = 0. nss is not used in this mode, and is not mapped to an external port pin through the crossbar. since there is no way of uniquely addressing the device in 3-wire slave mode , spi0 must be the only slav e device present on the bus. it is important to note that in 3-wire slave mode there is no external means of resetting the bit counter that determines when a full byte has been received. th e bit counter can only be reset by disabling and re- enabling spi0 with the spien bit. figure 21.3 shows a connection diagram between a slave device in 3- wire slave mode and a master device. 21.4. spi0 interrupt sources when spi0 interrupts are e nabled, the following four flags will gener ate an interrupt when they are set to logic 1: note that all of the following bits must be cleared by software. 1. the spi interrupt flag, spif (spi0cn.7) is set to logic 1 at the end of each byte transfer. this flag can occur in all spi0 modes. 2. the write collision flag, wcol (spi0cn.6) is set to logic 1 if a write to spi0dat is attempted when the transmit buffer has not been emptied to the spi shift register. when this occurs, the write to spi0dat will be ignored, and the transmi t buffer will not be writte n.this flag can occur in all spi0 modes. 3. the mode fault flag modf (spi0cn.5) is set to logic 1 when spi0 is configured as a master, and for multi-master mode and the nss pin is pulled low. when a mode fault occurs, the msten and spien bits in spi0cn are set to lo gic 0 to disable spi0 and allow another master device to access the bus. 4. the receive overrun flag rxovrn (spi0cn.4) is set to logic 1 when configured as a slave, and a transfer is completed and the receive buffer still holds an unread byte from a previous transfer. the new byte is not transferred to th e receive buffer, allowing the previously received data byte to be read. the data byte which caused the overrun is lost.
c8051f060/1/2/3/4/5/6/7 256 rev. 1.2 21.5. serial clock timing four combinations of serial clock phase and polarity can be selected using the clock control bits in the spi0 configuration register (spi0c fg). the ckpha bit ( spi0cfg.5) selects one of two clock phases (edge used to latch the data). the ckpol bit (spi0cfg.4) selects between an active-high or active-low clock. both master and slave devices must be config ured to use the same clock phase and polarity. spi0 should be disabled (by clearing the spien bit, spi0 cn.0) when changing the clock phase or polarity. the clock and data line relationships for master mode are shown in figure 21.5. for slave mode, the clock and data relationships are shown in figure 21.6 and figure 2 1.7. note that ckpha must be set to ?0? on both the master and slave spi when communicating betw een two of the following devices: c8051f04x, c8051f06x, c8051f12x, c8051f31x, c8051f32x, and c8051f33x the spi0 clock rate register (spi0ckr) as shown in figure 21.10 controls the ma ster mode serial clock frequency. this register is ignored when operating in slave mode. when the spi is configured as a master, the maximum data tran sfer rate (bits/sec) is one -half the system clock frequency or 12.5 mhz, whichever is slower. when the spi is configured as a slave, the maximum data transfer rate (bits/sec) for full-duplex operation is 1/10 the system clock frequency, provided that the master issues sck, nss (in 4-wire slave mode), and the serial input data synchronously with the slave?s system clock. if the master issues sck, nss, and the serial input data asynchronously, the maximum data transfer rate (bits/sec) must be less than 1/10 the system clock frequency. in the special case where the master only wants to transmit data to the slave and does not need to receive data from the slave (i.e. half-duplex operation), the spi slave can receive data at a maximum data transfe r rate (bits/sec) of 1/4 the system clock frequency. this is provided that the master issues sck, nss, and the serial in put data synchronously with the slave?s system clock. sck (ckpol=0, ckpha=0) sck (ckpol=0, ckpha=1) sck (ckpol=1, ckpha=0) sck (ckpol=1, ckpha=1) msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 miso/mosi nss (must remain high in multi-master mode) figure 21.5. master mode data/clock timing
c8051f060/1/2/3/4/5/6/7 rev. 1.2 257 msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 miso nss (4-wire mode) msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mosi sck (ckpol=0, ckpha=0) sck (ckpol=1, ckpha=0) figure 21.6. slave mode data/clock timing (ckpha = 0) sck (ckpol=0, ckpha=1) sck (ckpol=1, ckpha=1) msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 miso nss (4-wire mode) msb bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 mosi figure 21.7. slave mode data/clock timing (ckpha = 1)
c8051f060/1/2/3/4/5/6/7 258 rev. 1.2 21.6. spi special function registers spi0 is accessed and controlled through four special function registers in the system controller: spi0cn control register, spi0dat data register, spi0cf g configuration register, and spi0ckr clock rate register. the four special function registers related to the operation of the spi0 bus are described in the following figures. figure 21.8. spi0cfg: spi0 configuration register bit 7: spibsy: spi busy (read only). this bit is set to logic 1 when a spi transf er is in progress (master or slave mode). bit 6: msten: master mode enable. 0: disable master mode. operate in slave mode. 1: enable master mode. operate as a master. bit 5: ckpha: spi0 clock phase. this bit controls the spi0 clock phase. 0: data centered on first edge of sck period. ? 1: data centered on second edge of sck period. ? bit 4: ckpol: spi0 clock polarity. this bit controls the spi0 clock polarity. 0: sck line low in idle state. 1: sck line high in idle state. bit 3: slvsel: slave selected flag (read only). this bit is set to logic 1 whenever the nss pin is low indicating spi0 is the selected slave. it is cleared to logic 0 when nss is high (slave not selected). this bit does not indicate the instantaneous value at the nss pin, but ra ther a de-glitched version of the pin input. bit 2: nssin: nss instantaneous pin input (read only). this bit mimics the instantaneous value that is present on the nss port pin at the time that the register is read. this input is not de-glitched. bit 1: srmt: shift register empty (valid in slave mode, read only). this bit will be set to logic 1 when all data has been transferred in/out of the shift register, and there is no new information available to read from the transmit buffer or write to the receive buffer. it returns to logic 0 when a data byte is transferred to the shift register from the transmit buffer or by a transition on sck. note: srmt = 1 when in master mode. bit 0: rxbmt: receive buffer empty (valid in slave mode, read only). this bit will be set to logic 1 when the receiv e buffer has be en read and contains no new information. if there is new inform ation available in the receive buffer that has not been read, this bit will return to logic 0. note: rxbmt = 1 when in master mode. ? in slave mode, data on mosi is sampled in the center of each data bit. in master mode, data on miso is sampled one sysclk before the end of each data bit, to provide ma ximum settling time for the slave device. see table 21.1 for timing parameters. r r/w r/w r/w r r r r reset value spibsy msten ckpha ckpol slvsel nssin srmt rxbmt 00000111 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9a 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 259 figure 21.9. spi0cn: spi0 control register bit 7: spif: spi0 interrupt flag. this bit is set to logic 1 by hardware at the end of a data trans fer. if interrupts are enabled, setting this bit causes the cpu to vector to the spi0 interrupt service routine. this bit is not automatically cleared by hardware. it must be cleared by software. bit 6: wcol: write collision flag. this bit is set to logic 1 by hardware (and gene rates a spi0 interrupt) to indicate a write to the spi0 data register was attempted while a da ta transfer was in progress. it must be cleared by software. bit 5: modf: mode fault flag. this bit is set to logic 1 by hardware (and ge nerates a spi0 interrupt) when a master mode collision is detected (nss is low, msten = 1, and nssmd[1:0] = 01). this bit is not auto- matically cleared by hardware. it must be cleared by software. bit 4: rxovrn: receive overru n flag (slave mode only). this bit is set to logic 1 by hardware (and generates a spi0 interrupt) when the receive buffer still holds unread da ta from a previous transfer and the la st bit of the curr ent transfer is shifted into the spi0 shift register. this bit is not automatically cleare d by hardware. it must be cleared by software. bits 3-2: nssmd1-nssmd0 : slave select mode. selects between the following nss operation modes: (see section ?21.2. spi0 master mode operation? on page 253 and section ?21.3. spi0 slave mode operation? on page 255 ). 00: 3-wire slave or 3-wire master mode. nss signal is not routed to a port pin. 01: 4-wire slave or multi-master mode (defau lt). nss is always an input to the device. 1x: 4-wire single-master mode. nss signal is mapped as an ou tput from the device and will assume the value of nssmd0. bit 1: txbmt: transmit buffer empty. this bit will be set to logic 0 when new data ha s been written to the transmit buffer. when data in the transmit buffer is tr ansferred to the spi sh ift register, this bit will be set to logic 1, indicating that it is safe to writ e a new byte to the transmit buffer. bit 0: spien: spi0 enable. this bit enables/disables the spi. 0: spi disabled. 1: spi enabled. r/wr/wr/wr/wr/wr/w r r/wreset value spif wcol modf rxovrn nssmd1 nssmd0 txbmt spien 00000110 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0xf8 0
c8051f060/1/2/3/4/5/6/7 260 rev. 1.2 figure 21.10. spi0ckr: spi0 clock rate register bits 7-0: scr7-scr0: spi0 clock rate. these bits determine the frequency of the sck output when the spi0 module is configured for master mode operation. the sck clock frequ ency is a divided version of the system clock, and is given in the following equation, where sysclk is the system clock frequency and spi0ckr is the 8-bit value held in the spi0ckr register. for 0 <= spi0ckr <= 255 example: if sysclk = 2 m hz and spi0ckr = 0x04, r/w r/w r/w r/w r/w r/w r/w r/w reset value scr7 scr6 scr5 scr4 scr3 scr2 scr1 scr0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9d 0 f sck 2000000 241 + () --------------- ----------- = f sck 200 khz = f sck sysclk 2 spi 0 ckr 1 + () --------------- ------------------ --------------- - =
c8051f060/1/2/3/4/5/6/7 rev. 1.2 261 figure 21.11. spi0dat: spi0 data register bits 7-0: spi0dat: spi0 transmit and receive data. the spi0dat register is used to transmit an d receive spi0 data. writing data to spi0dat places the data into the transmit buffer and initiates a transfer when in master mode. a read of spi0dat returns the contents of the receive buffer. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x9b 0
c8051f060/1/2/3/4/5/6/7 262 rev. 1.2 sck* t mckh t mckl mosi t mis miso * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t mih figure 21.12. spi master timing (ckpha = 0) sck* t mckh t mckl miso t mih mosi * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t mis figure 21.13. spi master timing (ckpha = 1)
c8051f060/1/2/3/4/5/6/7 rev. 1.2 263 sck* t se nss t ckh t ckl mosi t sis t sih miso t sd t soh * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t sez t sdz figure 21.14. spi slave timing (ckpha = 0) sck* t se nss t ckh t ckl mosi t sis t sih miso t sd t soh * sck is shown for ckpol = 0. sck is the opposite polarity for ckpol = 1. t slh t sez t sdz figure 21.15. spi slave timing (ckpha = 1)
c8051f060/1/2/3/4/5/6/7 264 rev. 1.2 table 21.1. spi slave timing parameters parameter description min max units master mode timing ? (see figure 21.12 and figure 21.13) t mckh sck high time 1*t sysclk ns t mckl sck low time 1*t sysclk ns t mis miso valid to sck shift edge 1*t sysclk + 20 ns t mih sck shift edge to miso change 0 ns slave mode timing ? (see figure 21.14 and figure 21.15) t se nss falling to first sck edge 2*t sysclk ns t sd last sck edge to nss rising 2*t sysclk ns t sez nss falling to miso valid 4*t sysclk ns t sdz nss rising to miso high-z 4*t sysclk ns t ckh sck high time 5*t sysclk ns t ckl sck low time 5*t sysclk ns t sis mosi valid to sck sample edge 2*t sysclk ns t sih sck sample edge to mosi change 2*t sysclk ns t soh sck shift edge to miso change 4*t sysclk ns t slh last sck edge to mi so change (ckpha = 1 only) 6*t sysclk 8*t sysclk ns ? t sysclk is equal to one period of the device system clock (sysclk).
c8051f060/1/2/3/4/5/6/7 rev. 1.2 265 22. uart0 uart0 is an enhanced serial port with frame error detection and address recognition hardware. uart0 may operate in full-duplex asynchronous or half-d uplex synchronous modes, and mutiproccessor commu- nication is fully supported. receive data is buffered in a holding register, allowing uart0 to start reception of a second incoming data byte before software has finished reading the previ ous data byte. a receive overrun bit indicates when new received data is latc hed into the receive buffer before the previously received byte has been read. uart0 is accessed via its associated sfrs, serial c ontrol (scon0) and serial data buffer (sbuf0). the single sbuf0 location provides access to both tr ansmit and receive registers. reading scon0 accesses the receive register and writing scon0 accesses the transmit register. uart0 may be operated in polled or interrupt mode. uart0 has two sources of interrupts: a transmit interrupt flag, ti0 (scon0.1 ) set when transmission of a data byte is complete, and a receive interrupt flag, ri0 (scon0.0) set when reception of a data byte is complete. uart0 interrupt flags are not cleared by hardware when the cpu vectors to the interrupt servic e routine; they must be cleared manually by soft- ware. this allows software to determine the cause of the uart0 in terrupt (transmit complete or receive complete). figure 22.1. uart0 block diagram tx control tx clock tx irq zero detector send shift set q d clr stop bit gen. tb80 start data write to sbuf0 crossbar tx0 port i/o serial port (uart0) interrupt rx control start rx clock load sbuf 0x1ff shift en rx irq uart0 baud rate generation logic sfr bus input shift register (9 bits) frame error detection sbuf0 read sbuf0 sfr bus saddr0 saden0 match detect rb80 load sbuf0 crossbar rx0 sbuf0 address match scon0 s m 2 0 t b 8 0 r b 8 0 t i 0 r i 0 s m 1 0 s m 0 0 r e n 0 ssta0 t x c o l 0 s 0 t c l k 1 s 0 t c l k 1 s 0 r c l k 1 s 0 r c l k 1 r x o v 0 f e 0 s m o d 0 ti0 ri0
c8051f060/1/2/3/4/5/6/7 266 rev. 1.2 22.1. uart0 operational modes uart0 provides four operating modes (one synchronous and three asynchronous) selected by setting configuration bits in the scon0 register. these four modes offer different baud rates and communication protocols. the four modes are summarized in table 22.1. 22.1.1. mode 0: synchronous mode mode 0 provides synchronous, half-duplex communicati on. serial data is transmitted and received on the rx0 pin. the tx0 pin provides the shift clock for both transmit and receive. the mcu must be the master since it generates the shift clock for transmission in both directions (see the interconnect diagram in figure 22.3). data transmission begins when an instruction writes a data byte to the sbuf0 register. eight data bits are transferred lsb first (see the timing diagram in figure 22.2), and the ti0 transmit interrupt flag (scon0.1) is set at the end of the eighth bit time. data reception begins when the ren0 receive enable bit (scon0.4) is set to logic 1 and the ri0 receive in terrupt flag (scon0.0) is cleared. one cycle after the eighth bit is shifted in, the ri0 flag is set and rece ption stops until software clears the ri0 bit. an inter- rupt will occur if enabled when either ti0 or ri0 are set. table 22.1. uart0 modes mode synchronization baud clock data bits start/stop bits 0 synchronous sysclk / 12 8 none 1 asynchronous timer 1, 2, 3, or 4 overflow 8 1 start, 1 stop 2 asynchronous sysclk / 32 or sysclk / 64 9 1 start, 1 stop 3 asynchronous timer 1, 2, 3, or 4 overflow 9 1 start, 1 stop
c8051f060/1/2/3/4/5/6/7 rev. 1.2 267 the mode 0 baud rate is sysclk / 12 . rx0 is forced to open -drain in mode 0, and an external pull-up will typically be required. 22.1.2. mode 1: 8-bit uart, variable baud rate mode 1 provides standard asynchronous, full duplex communication using a total of 10 bits per data byte: one start bit, eight data bits (lsb first), and one stop bit. data are transmitted from the tx0 pin and received at the rx0 pin. on receive, the eight data bits are stored in sbuf0 and the stop bit goes into rb80 (scon0.2). data transmission begins when an instruction writes a data byte to the sbuf0 register. the ti0 transmit interrupt flag (scon0.1) is set at the end of the tran smission (the beginning of the stop-bit time). data reception can begin any time after the ren0 receive en able bit (scon0.4) is set to logic 1. after the stop bit is received, the data byte will be loaded into the sbuf0 receive register if the following conditions are met: ri0 must be logic 0, and if sm20 is logic 1, the stop bit must be logic 1. if these conditions are met, the eight bits of data is stored in sbuf0, the stop bit is stored in rb80 and the ri0 flag is set. if these conditio ns are not met, sbuf0 and rb80 will no t be loaded and the ri0 flag will not be set. an interrupt will occur if enabled when ei ther ti0 or ri0 are set. figure 22.2. uart0 mode 0 timing diagram d1 d0 d2 d3 d4 d5 d6 d7 rx (data out) mode 0 transmit d0 mode 0 receive rx (data in) d1 d2 d3 d4 d5 d6 d7 tx (clk out) tx (clk out) figure 22.3. uart0 mode 0 interconnect shift reg. clk c8051fxxx rx tx data 8 extra outputs figure 22.4. uart0 mode 1 timing diagram d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space
c8051f060/1/2/3/4/5/6/7 268 rev. 1.2 the baud rate generated in mode 1 is a function of timer overflow. uart0 can use timer 1 operating in 8- bit auto-reload mode , or timer 2, 3, or 4 operating in auto-reload mode to generate the baud rate (note that the tx and rx clocks are selected separately). on each timer overflow event (a rollover from all ones - (0xff for timer 1, 0xffff for timer 2, 3, or 4) - to zero) a clock is sent to the baud rate logic. timers 1, 2, 3, or 4 are selected as the baud rate source with bits in the ssta0 register (see figure 22.9). the transmit baud rate clock is selected using the s0tclk1 and s0tclk0 bits, and the receive baud rate clock is selected using the s0rclk1 and s0rclk0 bits. when timer 1 is selected as a baud rate source, the smod0 bit (ssta0.4) selects whether or not to divide the timer 1 overflow rate by two. on reset, the smod0 bit is logic 0, thus selecting the lower speed baud rate by default. the smod0 bit affects the baud rate generated by timer 1 as shown in equation 22.1. the timer 1 overflow rate is determined by the timer 1 clock source (t1clk) and reload value (th1). the frequency of t1clk is se lected as described in section ?24.1. timer 0 and timer 1? on page 287 . the timer 1 overflow rate is calculated as shown in equation 22.2. when timers 2, 3, or 4 are selected as a baud rate source, the baud rate is generated as shown in equation 22.3. the overflow rate for timer 2, 3, or 4 is determin ed by the clock source for the timer (tnclk) and the 16- bit reload value stored in the rcapn register (n = 2, 3, or 4), as shown in equation 22.4. equation 22.1. mode 1 baud rate using timer 1 mode1_baudrate 1 32 ? timer1_overflowrate ? = when smod0 = 0: mode1_baudrate 1 16 ? timer1_overflowrate ? = when smod0 = 1: equation 22.2. timer 1 overflow rate timer1_overflowrate t1clk 256 th1 ? () ? = equation 22.3. mode 1 baud rate using timer 2, 3, or 4 mode1_baudrate 1 16 ? timer234_overflowrate ? = equation 22.4. timer 2, 3, or 4 overflow rate timer234_overflowrate tnclk 65536 rcapn ? () ? =
c8051f060/1/2/3/4/5/6/7 rev. 1.2 269 22.1.3. mode 2: 9-bit uart, fixed baud rate mode 2 provides asynchronous, full-duplex communicatio n using a total of eleven bits per data byte: a start bit, 8 data bits (lsb first), a programmable ninth da ta bit, and a stop bit. mode 2 supports multiprocessor communications and hardware address recognition (see section 22.2 ). on transmit, the ninth data bit is determined by the value in tb80 (scon0.3). it can be as signed the value of the parity flag p in the psw or used in multiprocessor communications. on receive, the ninth data bit goes into rb80 (scon0.2) and the stop bit is ignored. data transmission begins when an instruction writes a data byte to the sbuf0 register. the ti0 transmit interrupt flag (scon0.1) is set at the end of the tran smission (the beginning of the stop-bit time). data reception can begin any time after the ren0 receive en able bit (scon0.4) is set to logic 1. after the stop bit is received, the data byte will be loaded into the sbuf0 re ceive register if ri0 is logic 0 and one of the following requirements are met: 1. sm20 is logic 0 2. sm20 is logic 1, the received 9th bit is l ogic 1, and the received ad dress matches the uart0 address as described in section 22.2 . if the above conditions are satisfied, the eight bits of data are stored in sbuf0, the ninth bit is stored in rb80 and the ri0 flag is set. if these conditions are not met, sbuf0 and rb80 will not be loaded and the ri0 flag will not be set. an in terrupt will occur if enabled when either ti0 or ri0 are set. the baud rate in mode 2 is either sysclk / 32 or sysclk / 64, according to the value of the smod0 bit in register ssta0. equation 22.5. mode 2 baud rate baudrate 2 smod 0 sysclk 64 ------------ --------- - ?? ?? = figure 22.5. uart0 modes 2 and 3 timing diagram d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space d8
c8051f060/1/2/3/4/5/6/7 270 rev. 1.2 22.1.4. mode 3: 9-bit uart, variable baud rate mode 3 uses the mode 2 transmission protocol with the mode 1 baud ra te generation. mode 3 operation transmits 11 bits: a start bit, 8 data bits (lsb first), a programmable ninth data bit, and a stop bit. the baud rate is derived from timer 1 or timer 2, 3, or 4 overfl ows, as defined by equation 22.1 and equation 22.3. multiprocessor communications and hardware addr ess recognition are supported, as described in section 22.2 . fi gure 22 . 6 . uart0 m o d es 1 , 2 , an d 3 i n t erconnec t di agram or rs-232 c8051fxxx rs-232 level xltr tx rx c8051fxxx rx tx mcu rx tx
c8051f060/1/2/3/4/5/6/7 rev. 1.2 271 22.2. multiprocessor communications modes 2 and 3 support multiprocessor communication between a master processor and one or more slave processors by special use of the ninth data bit and the built-in uart0 address recognition hardware. when a master processor wants to transmit to one or more sl aves, it first sends an address byte to select the tar- get(s). an address byte differs from a data byte in that its ninth bit is logic 1; in a data byte, the ninth bit is always set to logic 0. uart0 will recognize as ?v alid? (i.e., capable of causing an interrupt) two types of addresses: (1) a masked address and (2) a broadcast address at any given time . both are described below. 22.2.1. configuration of a masked address the uart0 address is configured via two sfrs: sa ddr0 (serial address) and saden0 (serial address enable). saden0 sets the bit mask for the address he ld in saddr0: bits set to logic 1 in saden0 corre- spond to bits in saddr0 that are checked against the received address byte; bits set to logic 0 in saden0 correspond to ?don?t care? bits in saddr0. setting the sm20 bit (sco n0.5) configures uart0 such that when a stop bit is received, uart0 will gen- erate an interrupt only if the ninth bit is logic 1 (rb8 0 = ?1?) and the received data byte matches the uart0 slave address. following th e received address interr upt, the slave will clear it s sm20 bit to enable inter- rupts on the reception of the following data byte(s). once the entire message is received, the addressed slave resets its sm20 bit to ignore all transmissions until it receives the next address byte. while sm20 is logic 1, uart0 ignores all bytes that do not match th e uart0 address and include a ninth bit that is logic 1. 22.2.2. broadcast addressing multiple addresses can be assigned to a single sl ave and/or a single address can be assigned to multiple slaves, thereby enabling "broadcast" transmissions to more than one slave simultaneously. the broadcast address is the logical or of registers saddr0 and saden0, and ?0?s of the result are treated as ?don?t cares?. typically a broadcast address of 0xff (hex adecimal) is acknowledged by all slaves, assuming ?don?t care? bits as ?1?s. the master processor can be configured to receive all transmissions or a protocol can be implemented such that the master/slave role is temporarily reversed to enable half-duplex trans- mission between the original master and slave(s).. note in the above examples 4, 5, and 6, each slave woul d recognize as ?valid? an address of 0xff as a broadcast address. also note that examples 4, 5, and 6 uses t he same saddr0 and saden0 register values as shown in the examples 1, 2, and 3 respec tively (slaves #1, 2, and 3). thus, a master could address each slave device individually using a masked address, and also broadcast to all three slave devices. for example, if a master were to send an address ?11110101?, only slave #1 would recognize the example 1, slave #1 example 2, slave #2 example 3, slave #3 saddr0 = 00110101 saddr0 = 00110101 saddr0 = 00110101 saden0 = 00001111 saden0 = 11110011 saden0 = 11000000 uart0 address = xxxx0101 uart0 address = 0011xx01 uart0 address = 00xxxxxx example 4, slave #1 example 5, slave #2 example 6, slave #3 saddr0 = 00110101 saddr0 = 00110101 saddr0 = 00110101 saden0 = 00001111 saden0 = 11110011 saden0 = 11000000 broadcast address = 00111111 broadcast address = 11110111 broadcast address = 11110101 where all zeroes in the broadcast address are don?t cares.
c8051f060/1/2/3/4/5/6/7 272 rev. 1.2 address as valid. if a master were to then send an address of ?11111111?, all three slave devices would rec- ognize the address as a valid broadcast address. 22.3. frame and transmi ssion error detection all modes: the transmit collision bit (t xcol0 bit in register scon0) reads ?1? if user software writes data to the sbuf0 register while a transmit is in progress. note that the txcol0 bit is also used as the sm20 bit when written by user software. this bit does not generate an interrupt. modes 1, 2, and 3: the receive overrun bit (rxov0 in register scon0) read s ?1? if a new data byte is latched into the receive buffer before software has read the previous byte. no te that the rxov0 bit is also used as the sm10 bit when written by user software. the frame error bit (fe0 in register ssta0) reads ?1? if an invalid (low) stop bit is detected. note that the fe0 bit is also used as the sm00 bit when written by user software. the rxov0 and fe0 bits do not generate interrupts. figure 22.7. uart multi-processor mode interconnect diagram master device slave device tx rx rx tx slave device rx tx slave device rx tx +5v
c8051f060/1/2/3/4/5/6/7 rev. 1.2 273 table 22.2. oscillator frequencies for standard baud rates oscillator frequency (mhz) divide fac- tor timer 1 reload value* timer2,3,or 4 reload value resulting baud rate (hz)** 24.0 208 0xf3 0xfff3 115200 (115384) 22.1184 192 0xf4 0xfff4 115200 18.432 160 0xf6 0xfff6 115200 11.0592 96 0xfa 0xfffa 115200 3.6864 32 0xfe 0xfffe 115200 1.8432 16 0xff 0xffff 115200 24.0 832 0xcc 0xffcc 28800 (28846) 22.1184 768 0xd0 0xffd0 28800 18.432 640 0xd8 0xffd8 28800 11.0592 348 0xe8 0xffe8 28800 3.6864 128 0xf8 0xfff8 28800 1.8432 64 0xfc 0xfffc 28800 24.0 2496 0x64 0xff64 9600 (9615) 22.1184 2304 0x70 0xff70 9600 18.432 1920 0x88 0xff88 9600 11.0592 1152 0xb8 0xffb8 9600 3.6864 384 0xe8 0xffe8 9600 1.8432 192 0xf4 0xfff4 9600 * assumes smod0=1 and t1m=1. ** numbers in parenthesis show the actual baud rate.
c8051f060/1/2/3/4/5/6/7 274 rev. 1.2 figure 22.8. scon0: uart0 control register bits7-6: sm00-sm10: serial port operation mode: write: when written, these bits select the se rial port operation mode as follows: reading these bits returns the current uart0 mode as defined above. bit5: sm20: multiprocesso r communication enable. the function of this bit is dependen t on the serial port operation mode. mode 0: no effect. mode 1: checks for valid stop bit. 0: logic level of stop bit is ignored. 1: ri0 will only be activated if stop bit is logic level 1. mode 2 and 3: multiprocessor communications enable. 0: logic level of ninth bit is ignored. 1: ri0 is set and an interrupt is generated only when the ninth bit is logic 1 and the received address matches the uart0 address or the broadcast address. bit4: ren0: receive enable. this bit enables/disables the uart0 receiver. 0: uart0 reception disabled. 1: uart0 reception enabled. bit3: tb80: ninth transmission bit. the logic level of this bit will be assigned to the ninth transmission bit in modes 2 and 3. it is not used in modes 0 and 1. set or cleared by software as required. bit2: rb80: ninth receive bit. the bit is assigned the logic level of the ninth bit received in modes 2 and 3. in mode 1, if sm20 is logic 0, rb80 is assigned the logic leve l of the received stop bit. rb8 is not used in mode 0. bit1: ti0: transmit interrupt flag. set by hardware when a byte of data has been transmitted by uart0 (after the 8th bit in mode 0, or at the beginning of the stop bit in other modes). when the uart0 interrupt is enabled, setting this bit causes the cpu to ve ctor to the uart0 inte rrupt service routine. this bit must be cleared manually by software. bit0: ri0: receive interrupt flag. set by hardware when a byte of data has been received by uart0 (as selected by the sm20 bit). when the uart0 interrupt is enabled, setting this bit causes the cpu to vector to the uart0 interrupt service routine. this bi t must be cleared manually by software. r/w r/w r/w r/w r/w r/w r/w r/w reset value sm00 sm10 sm20 ren0 tb80 rb80 ti0 ri0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x98 0 sm00 sm10 mode 0 0 mode 0: synchronous mode 0 1 mode 1: 8-bit uart, variable baud rate 1 0 mode 2: 9-bit uart, fixed baud rate 1 1 mode 3: 9-bit uart, variable baud rate
c8051f060/1/2/3/4/5/6/7 rev. 1.2 275 figure 22.9. ssta0: uart0 status and clock sel ection register bit7: fe0: frame error flag. ? this flag indicates if an inva lid (low) stop bit is detected. 0: frame error has not been detected. 1: frame error has been detected. bit6: rxov0: receive overrun flag. ? this flag indicates new data has been latched into the receive buffer before software has read the previous byte. 0: receive overrun has not been detected. 1: receive overrun has been detected. bit5: txcol0: transmit collision flag. ? this flag indicates user software has written to the sbuf0 register while a transmission is in progress. 0: transmission collisio n has not been detected. 1: transmission collisio n has been detected. bit4: smod0: uart0 baud rate doubler enable. this bit enables/disables the divide-by-two fu nction of the uart0 baud rate logic for config- urations described in the uart0 section. 0: uart0 baud rate divide-by-two enabled. 1: uart0 baud rate divide-by-two disabled. bits3-2: uart0 transmit baud rate clock selection bits. bits1-0: uart0 receive baud rate clock selection bits. ? note: fe0, rxov0, and txcol0 are flags only, an d no interrupt is generated by these conditions. r/w r/w r/w r/w r/w r/w r/w r/w reset value fe0 rxov0 txcol0 smod0 s0tclk1 s0tclk0 s0rclk1 s0rclk0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x91 0 s0tclk1 s0tclk0 serial transmit baud rate clock source 0 0 timer 1 generates uart0 tx baud rate 0 1 timer 2 overflow generates uart0 tx baud rate 1 0 timer 3 overflow generates uart0 tx baud rate 1 1 timer 4 overflow generates uart0 tx baud rate s0rclk1 s0rclk0 serial receive baud rate clock source 0 0 timer 1 generates uart0 rx baud rate 0 1 timer 2 overflow generates uart0 rx baud rate 1 0 timer 3 overflow generates uart0 rx baud rate 1 1 timer 4 overflow generates uart0 rx baud rate
c8051f060/1/2/3/4/5/6/7 276 rev. 1.2 figure 22.10. sbuf0: uart0 data buffer register bits7-0: sbuf0.[7:0]: uart0 bu ffer bits 7-0 (msb-lsb). this is actually two registers; a transmit and a receive buffer register. when data is moved to sbuf0, it goes to the transmit buffer and is held for serial transmission. moving a byte to sbuf0 is what initiates the transmission. when data is moved from sbuf0, it comes from the receive buffer. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x99 0 figure 22.11. saddr0: uart0 slave address register bits7-0: saddr0.[7:0]: uart0 slave address. the contents of this register are used to define the uart0 slave address. register saden0 is a bit mask to determine which bits of sa ddr0 are checked against a received address: corresponding bits set to logic 1 in saden0 are checked; corresponding bits set to logic 0 are ?don?t cares?. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xa9 0 figure 22.12. saden0: uart0 slave address enable register bits7-0: saden0.[7:0]: uart0 slave address enable. bits in this register enable corresponding bits in register saddr0 to determine the uart0 slave address. 0: corresponding bit in saddr0 is a ?don?t care?. 1: corresponding bit in saddr0 is checked against a received address. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xb9 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 277 23. uart1 uart1 is an asynchronous, full duplex serial port offering modes 1 and 3 of the standard 8051 uart. enhanced baud rate support allows a wide range of clock sources to generate standard baud rates (details in section ?23.1. enhanced baud rate generation? on page 278 ). received data buffering allows uart1 to start reception of a second incoming data byte be fore software has finished reading the previous data byte. uart1 has two associated sfrs: serial control regist er 1 (scon1) and serial data buffer 1 (sbuf1). the single sbuf1 location provides access to both transmit and receive registers. reading sbuf1 accesses the buffered receive re gister; writing sbuf1 access es the transmit register. with uart1 interrupts enabled, an interrupt is generated each time a transmit is completed (ti1 is set in scon1), or a data byte has been received (ri1 is set in scon1). the uart1 interrupt flags are not cleared by hardware when the cpu vectors to the inte rrupt service routine. they must be cleared manually by software, allowing software to determine the cause of the uart1 interrupt (transmit complete or receive complete). figure 23.1. uart1 block diagram uart1 baud rate generator ri1 scon1 ri1 ti1 rb81 tb81 ren1 mce1 s1mode tx control tx clock send sbuf1 (tx shift) start data write to sbuf1 crossbar tx1 shift zero detector tx irq set q d clr stop bit tb81 sfr bus serial port interrupt ti1 port i/o rx control start rx clock load sbuf1 shift 0x1ff rb81 rx irq input shift register (9 bits) load sbuf1 read sbuf1 sfr bus crossbar rx1 sbuf1 (rx latch)
c8051f060/1/2/3/4/5/6/7 278 rev. 1.2 23.1. enhanced baud rate generation the uart1 baud rate is generated by timer 1 in 8-bit auto-reload mode. the tx clock is generated by tl1; the rx clock is generated by a copy of tl1 (shown as rx timer in figure 23.2), which is not user- accessible. both tx and rx timer overflows are divided by two to generate the tx and rx baud rates. the rx timer runs when timer 1 is enabled, and uses the same reload value (th1). however, an rx timer reload is forced when a start condition is detected on the rx pin. this allows a receive to begin any time a start is detected, independent of the tx timer state. timer 1 should be configured for mode 2, 8-bit auto-reload (see section ?24.1.3. mode 2: 8-bit counter/ timer with auto-reload? on page 289 ). the timer 1 reload value should be set so that overflows will occur at two times the desired baud rate. note that timer 1 may be clocked by one of five sources: sysclk, sysclk / 4, sysclk / 12, sysclk / 48, or the external o scillator clock / 8. for any given timer 1 clock source, the uart1 baud rate is determined by equation 23.1. where t1 clk is the frequency of the clock supplied to timer 1, and t1h is the high byte of timer 1 (reload value). timer 1 clock frequency is selected as described in section ?24.1. timer 0 and timer 1? on page 287 . a quick reference for typical baud rates and system clock frequencies is given in table 23.1 through table 23.6. note th at the internal oscillator may still generate the syst em clock when the external oscillator is driving timer 1 (see section ?24.1. timer 0 and timer 1? on page 287 for more details). figure 23.2. uart1 baud rate logic rx timer start detected overflow overflow th1 tl1 tx clock 2 rx clock 2 timer 1 uart1 equation 23.1. uart1 baud rate uartbaudrate t 1 clk 256 t 1 h ? () ----------------- ------------- - 1 2 -- - =
c8051f060/1/2/3/4/5/6/7 rev. 1.2 279 23.2. operational modes uart1 provides standard asynchronous, full duplex communication. the uart mode (8-bit or 9-bit) is selected by the s1mode bit (scon1.7). typical uart connection options are shown below. 23.2.1. 8-bit uart 8-bit uart mode uses a total of 10 bits per data byte: one start bit, eight data bits (lsb first), and one stop bit. data are transmitted lsb first from the tx1 pin and received at the rx1 pin. on receive, the eight data bits are stored in sbuf1 and the stop bit goes into rb81 (scon1.2). data transmission begins wh en software writes a data byte to th e sbuf1 register. the ti1 transmit inter- rupt flag (scon1.1) is set at the end of the transmi ssion (the beginning of the st op-bit time). data recep- tion can begin any time after the ren1 receive enable bit (scon1.4) is set to logic 1. after the stop bit is received, the data byte w ill be loaded into the sbuf1 re ceive register if the follo wing conditions are met: ri1 must be logic 0, and if mce1 is logic 1, the stop bi t must be logic 1. in the event of a receive data over- run, the first received 8 bits are latched into the sbu f1 receive register and the following overrun data bits are lost. if these conditions are met, the eight bits of data is stored in sbuf1, the stop bit is stored in rb81 and the ri1 flag is set. if these conditio ns are not met, sbuf1 and rb81 will no t be loaded and the ri1 flag will not be set. an interrupt will o ccur if enabled when eith er ti1 or ri1 is set. figure 23.3. uart interconnect diagram or rs-232 c8051fxxx rs-232 level xltr tx rx c8051fxxx rx tx mcu rx tx figure 23.4. 8-bit uart timing diagram d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space
c8051f060/1/2/3/4/5/6/7 280 rev. 1.2 23.2.2. 9-bit uart 9-bit uart mode uses a total of eleven bits per data byte: a start bit, 8 data bits (lsb first), a programma- ble ninth data bit, and a stop bit. the state of the nint h transmit data bit is determ ined by the value in tb81 (scon1.3), which is assigned by user software. it can be assigned the value of the parity flag (bit p in reg- ister psw) for error detection, or used in multiprocessor communications. on receive, the ninth data bit goes into rb81 (scon1.2) and the stop bit is ignored. data transmission begins when an instruction writes a data byte to the sbuf1 register. the ti1 transmit interrupt flag (scon1.1) is set at the end of the tran smission (the beginning of the stop-bit time). data reception can begin any time after the ren1 receive en able bit (scon1.4) is set to ?1?. after the stop bit is received, the data byte will be lo aded into the sbuf1 receiv e register if the follo wing conditio ns are met: (1) ri1 must be logic 0, and (2) if mce1 is logic 1, the 9th bit must be logic 1 (when mce1 is logic 0, the state of the ninth data bit is unimportant). if these co nditions are met, the eight bits of data are stored in sbuf1, the ninth bit is stored in rb81, and the ri1 flag is set to ?1?. if the above conditions are not met, sbuf1 and rb81 will not be loaded and the ri1 flag will not be set to ?1?. a ua rt1 interrupt will occur if enabled when either ti1 or ri1 is set to ?1?. figure 23.5. 9-bit uart timing diagram d1 d0 d2 d3 d4 d5 d6 d7 start bit mark stop bit bit times bit sampling space d8
c8051f060/1/2/3/4/5/6/7 rev. 1.2 281 23.3. multiprocessor communications 9-bit uart mode supports multiprocessor communication between a master processor and one or more slave processors by special use of the ninth data bit. when a master processor wants to transmit to one or more slaves, it first sends an address byte to select the target(s). an address byte differs from a data byte in that its ninth bit is logic 1; in a data byte, the ninth bit is always set to logic 0. setting the mce1 bit (scon.5) of a slave processor configures its uart such that when a stop bit is received, the uart will generate an interrupt only if the ninth bit is logic one (rb81 = 1) signifying an address byte has been received. in the uart interrupt handler, software should compare the received address with the slave's own assigned 8-bit address. if the addresses match, the slave should clear its mce1 bit to enable interrupts on the reception of the following data byte(s). slaves that weren't addressed leave their mce1 bits set and do not generate interrupts on the reception of the following data bytes, thereby ignoring the data. once the entire message is received, the addressed slave should reset its mce1 bit to ignore all transmissions until it receives the next address byte. multiple addresses can be assigned to a single sl ave and/or a single address can be assigned to multiple slaves, thereby enabling "broadcast" transmissions to more than one slave simultaneously. the master processor can be configured to receive all transmissi ons or a protocol can be implemented such that the master/slave role is tem porarily reversed to enable half-duplex transmission between the original master and slave(s). figure 23.6. uart multi-processor mode interconnect diagram master device slave device tx rx rx tx slave device rx tx slave device rx tx +5v
c8051f060/1/2/3/4/5/6/7 282 rev. 1.2 figure 23.7. scon1: serial port 1 control register bit7: s1mode: serial port 1 operation mode. this bit selects the uart1 operation mode. 0: 8-bit uart with variable baud rate. 1: 9-bit uart with variable baud rate. bit6: unused. read = 1b . write = don?t care. bit5: mce1: multiprocessor communication enable. the function of this bit is dependent on the serial port 0 operation mode. s1mode = 0: checks for valid stop bit. 0: logic level of stop bit is ignored. 1: ri1 will only be activated if stop bit is logic level 1. s1mode = 1: multiprocesso r communications enable. 0: logic level of ninth bit is ignored. 1: ri1 is set and an interrupt is generated only when the ninth bit is logic 1. bit4: ren1: receive enable. this bit enables/disables the uart receiver. 0: uart1 reception disabled. 1: uart1 reception enabled. bit3: tb81: ninth transmission bit. the logic level of this bit will be assigned to the ninth transmission bit in 9-bit uart mode. it is not used in 8-bit uart mode. set or cleared by software as required. bit2: rb81: ninth receive bit. rb81 is assigned the value of the stop bit in mode 0; it is assigned the value of the 9th data bit in mode 1. bit1: ti1: transmit interrupt flag. set by hardware when a byte of data has been transmitted by uart1 (after the 8th bit in 8- bit uart mode, or at the beginning of the stop bit in 9-bit uart mode). when the uart1 interrupt is enabled, setting this bit causes the cpu to vector to the uart1 interrupt service routine. this bit must be cleared manually by software. bit0: ri1: receive interrupt flag. set to ?1? by hardware when a byte of data has been received by uart1 (set at the stop bit sampling time). when the uart1 interrupt is enab led, setting this bit to ?1? causes the cpu to vector to the uart1 interrup t service routine. this bit must be cleared manually by soft- ware. r/w r/w r/w r/w r/w r/w r/w r/w reset value s1mode - mce1 ren1 tb81 rb81 ti1 ri1 01000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x98 1
c8051f060/1/2/3/4/5/6/7 rev. 1.2 283 figure 23.8. sbuf1: serial (uart1) port data buffer register bits7-0: sbuf1[7:0]: serial data buffer bits 7-0 (msb-lsb). this sfr accesses two registers; a transmit shif t register and a receive latch register. when data is written to sbuf1, it goes to the transmit shift register and is he ld for serial transmis- sion. writing a byte to sbuf1 is what initiate s the transmission. a read of sbuf1 returns the contents of the receive latch. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x99 1
c8051f060/1/2/3/4/5/6/7 284 rev. 1.2 table 23.1. timer settings for standard baud rates using the internal oscillator frequency: 24.5 mhz target baud rate (bps) baud rate % error oscilla- tor divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload value (hex) sysclk from internal osc. 230400 -0.32% 106 sysclk xx 1 0xcb 115200 -0.32% 212 sysclk xx 1 0x96 57600 0.15% 426 sysclk xx 1 0x2b 28800 -0.32% 848 sysclk / 4 01 0 0x96 14400 0.15% 1704 sysclk / 12 00 0 0xb9 9600 -0.32% 2544 sysclk / 12 00 0 0x96 2400 -0.32% 10176 sysc lk / 48 10 0 0x96 1200 0.15% 20448 sysclk / 48 10 0 0x2b x = don?t care ? sca1-sca0 and t1m bit definitions can be found in section 24.1 . table 23.2. timer settings for standard baud rates using an external oscillator frequency: 25.0 mhz target baud rate (bps) baud rate % error oscilla- tor divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload value (hex) sysclk from external osc. 230400 -0.47% 108 sysclk xx 1 0xca 115200 0.45% 218 sysclk xx 1 0x93 57600 -0.01% 434 sysclk xx 1 0x27 28800 0.45% 872 sysclk / 4 01 0 0x93 14400 -0.01% 1736 sysclk / 4 01 0 0x27 9600 0.15% 2608 extclk / 8 11 0 0x5d 2400 0.45% 10464 sysc lk / 48 10 0 0x93 1200 -0.01% 20832 sysclk / 48 10 0 0x27 sysclk from internal osc. 57600 -0.47% 432 extclk / 8 11 0 0xe5 28800 -0.47% 864 extclk / 8 11 0 0xca 14400 0.45% 1744 extclk / 8 11 0 0x93 9600 0.15% 2608 extclk / 8 11 0 0x5d x = don?t care ? sca1-sca0 and t1m bit definitions can be found in section 24.1 .
c8051f060/1/2/3/4/5/6/7 rev. 1.2 285 table 23.3. timer settings for standard baud rates using an external oscillator frequency: 22.1184 mhz target baud rate (bps) baud rate % error oscilla- tor divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload value (hex) sysclk from external osc. 230400 0.00% 96 sysclk xx 1 0xd0 115200 0.00% 192 sysclk xx 1 0xa0 57600 0.00% 384 sysclk xx 1 0x40 28800 0.00% 768 sysclk / 12 00 0 0xe0 14400 0.00% 1536 sysclk / 12 00 0 0xc0 9600 0.00% 2304 sysclk / 12 00 0 0xa0 2400 0.00% 9216 sysclk / 48 10 0 0xa0 1200 0.00% 18432 sysclk / 48 10 0 0x40 sysclk from internal osc. 230400 0.00% 96 extclk / 8 11 0 0xfa 115200 0.00% 192 extclk / 8 11 0 0xf4 57600 0.00% 384 extclk / 8 11 0 0xe8 28800 0.00% 768 extclk / 8 11 0 0xd0 14400 0.00% 1536 extclk / 8 11 0 0xa0 9600 0.00% 2304 extclk / 8 11 0 0x70 x = don?t care ? sca1-sca0 and t1m bit definitions can be found in section 24.1 . table 23.4. timer settings for standard baud rates using an external oscillator frequency: 18.432 mhz target baud rate (bps) baud rate % error oscilla- tor divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload value (hex) sysclk from external osc. 230400 0.00% 80 sysclk xx 1 0xd8 115200 0.00% 160 sysclk xx 1 0xb0 57600 0.00% 320 sysclk xx 1 0x60 28800 0.00% 640 sysclk / 4 01 0 0xb0 14400 0.00% 1280 sysclk / 4 01 0 0x60 9600 0.00% 1920 sysclk / 12 00 0 0xb0 2400 0.00% 7680 sysclk / 48 10 0 0xb0 1200 0.00% 15360 sysclk / 48 10 0 0x60 sysclk from internal osc. 230400 0.00% 80 extclk / 8 11 0 0xfb 115200 0.00% 160 extclk / 8 11 0 0xf6 57600 0.00% 320 extclk / 8 11 0 0xec 28800 0.00% 640 extclk / 8 11 0 0xd8 14400 0.00% 1280 extclk / 8 11 0 0xb0 9600 0.00% 1920 extclk / 8 11 0 0x88 x = don?t care ? sca1-sca0 and t1m bit definitions can be found in section 24.1 .
c8051f060/1/2/3/4/5/6/7 286 rev. 1.2 table 23.5. timer settings for standard baud rates using an external oscillator frequency: 11.0592 mhz target baud rate (bps) baud rate % error oscilla- tor divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload value (hex) sysclk from external osc. 230400 0.00% 48 sysclk xx 1 0xe8 115200 0.00% 96 sysclk xx 1 0xd0 57600 0.00% 192 sysclk xx 1 0xa0 28800 0.00% 384 sysclk xx 1 0x40 14400 0.00% 768 sysclk / 12 00 0 0xe0 9600 0.00% 1152 sysclk / 12 00 0 0xd0 2400 0.00% 4608 sysclk / 12 00 0 0x40 1200 0.00% 9216 sysclk / 48 10 0 0xa0 sysclk from internal osc. 230400 0.00% 48 extclk / 8 11 0 0xfd 115200 0.00% 96 extclk / 8 11 0 0xfa 57600 0.00% 192 extclk / 8 11 0 0xf4 28800 0.00% 384 extclk / 8 11 0 0xe8 14400 0.00% 768 extclk / 8 11 0 0xd0 9600 0.00% 1152 extclk / 8 11 0 0xb8 x = don?t care ? sca1-sca0 and t1m bit definitions can be found in section 24.1 . table 23.6. timer settings for standard baud rates using an external oscillator frequency: 3.6864 mhz target baud rate (bps) baud rate % error oscilla- tor divide factor timer clock source sca1-sca0 (pre-scale select) ? t1m ? timer 1 reload value (hex) sysclk from external osc. 230400 0.00% 16 sysclk xx 1 0xf8 115200 0.00% 32 sysclk xx 1 0xf0 57600 0.00% 64 sysclk xx 1 0xe0 28800 0.00% 128 sysclk xx 1 0xc0 14400 0.00% 256 sysclk xx 1 0x80 9600 0.00% 384 sysclk xx 1 0x40 2400 0.00% 1536 sysclk / 12 00 0 0xc0 1200 0.00% 3072 sysclk / 12 00 0 0x80 sysclk from internal osc. 230400 0.00% 16 extclk / 8 11 0 0xff 115200 0.00% 32 extclk / 8 11 0 0xfe 57600 0.00% 64 extclk / 8 11 0 0xfc 28800 0.00% 128 extclk / 8 11 0 0xf8 14400 0.00% 256 extclk / 8 11 0 0xf0 9600 0.00% 384 extclk / 8 11 0 0xe8 x = don?t care ? sca1-sca0 and t1m bit definitions can be found in section 24.1 .
c8051f060/1/2/3/4/5/6/7 rev. 1.2 287 24. timers each mcu includes 5 counter/timers: timer 0 and time r 1 are 16-bit counter/timers compatible with those found in the standard 8051. timer 2, timer 3, and timer 4 are 16-bit auto-reload and capture counter/tim- ers for use with the adc?s, dac?s, square-wave generat ion, or for general-purpose use. these timers can be used to measure time intervals, count external events and generate periodic interrupt requests. timer 0 and timer 1 are nearly identical and have four primary modes of operation. timers 2, 3, and 4 are identi- cal, and offer not only 16-bit auto -reload and capture, but have the ability to produce a 50% duty-cycle square-wave (toggle output) at an external port pin. timers 0 and 1 may be clocked by one of five source s, determined by the timer mode select bits (t1m- t0m) and the clock scale bits (sca1-sca0). the cl ock scale bits define a pre-scaled clock by which timer 0 and/or timer 1 may be clocked (see figure 24.6 for pre-scaled clock selection). timers 0 and 1 can be configured to use either the pre-scaled clock signal or the system clock directly. timers 2, 3, and 4 may be clocked by the system clock, the system clock divided by 12, or the exte rnal oscillator clock source divided by 8. timer 0 and timer 1 may also be operated as counte rs. when functioning as a counter, a counter/timer register is incremented on each high -to-low transition at the selected input pin. events with a frequency of up to one-fourth the system clock's frequency can be counted. the input signal need not be periodic, but it should be held at a given logic level for at least two fu ll system clock cycles to en sure the level is properly sampled. 24.1. timer 0 and timer 1 each timer is implemented as a 16-bit register ac cessed as two separate 8-bit sfrs: a low byte (tl0 or tl1) and a high byte (th0 or th1). the counter/time r control register (tcon) is used to enable timer 0 and timer 1 as well as indicate their status. timer 0 in terrupts can be enabled by setting the et0 bit in the ie register ( section ?13.3.5. interrupt register descriptions? on page 154 ); timer 1 interrupts can be enabled by setting the et1 bit in the ie register ( section 13.3.5 ). both counter/timers operate in one of four primary modes selected by setting the mode select bits t1m1-t0m0 in the counter/timer mode register (tmod). both timers can be configured independently. 24.1.1. mode 0: 13-bit counter/timer timer 0 and timer 1 operate as 13-bit counter/timers in mode 0. the following describes the configuration and operation of timer 0. however, both timers oper ate identically, and timer 1 is configured in the same manner as described for timer 0. the th0 register holds the eight msbs of the 13-bit c ounter/timer. tl0 holds the five lsbs in bit positions tl0.4-tl0.0. the three upper bits of tl0 (tl0.7-tl0 .5) are indeterminate and should be masked out or ignored when reading the tl0 register. as the 13-bit timer register increments and overflows from 0x1fff (all ones) to 0x0000, the ti mer overflow flag tf0 (tcon.5) is set an d an interrupt will occur if timer 0 inter- rupts are enabled. timer 0 and timer 1 modes: timer 2, 3, and 4 modes: 13-bit counter/timer 16-bit counter/timer with auto-reload 16-bit counter/timer 16-bit counter/timer with capture 8-bit counter/timer with auto-reload toggle output two 8-bit counter/timers (timer 0 only)
c8051f060/1/2/3/4/5/6/7 288 rev. 1.2 the c/t0 bit (tmod.2) selects the counter/timer's cloc k source. when c/t0 is set to logic 1, high-to-low transitions at the selected timer 0 input pin (t 0) increment the timer register (refer to section ?18.1. ports 0 through 3 and the priority crossbar decoder? on page 205 for information on selecting and configuring external i/o pins). clearing c/t select s the clock defined by the t0m bit (ckcon.3). when t0m is set, timer 0 is clocked by th e system clock. when t0m is clear ed, timer 0 is clocked by the source selected by the clock scale bits in ckcon (see figure 24.6). setting the tr0 bit (tcon.4) enables the timer when ei ther gate0 (tmod.3) is logic 0 or the input signal /int0 is logic-level 1. setting gate0 to ?1? allows the timer to be controlled by the external input signal / int0 (see section ?13.3.5. interrupt register descriptions? on page 154 ), facilitating pulse width measure- ments. setting tr0 does not force the timer to reset. the timer registers should be loaded with the desired initial value before the timer is enabled. tl1 and th1 form the 13-bit register for timer 1 in the same manner as described above for tl0 and th0. timer 1 is configured and controlled using the relevant tcon and tmod bits just as with timer 0. the input signal /int1 is used with timer 1. tr0 gate0 /int0 counter/timer 0 x x disabled 1 0 x enabled 1 1 0 disabled 111 enabled x = don't care figure 24.1. t0 mode 0 block diagram tclk tl0 (5 bits) th0 (8 bits) tcon tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt tr0 0 1 0 1 sysclk pre-scaled clock ckcon s c a 0 s c a 1 t 1 m t 0 m tmod t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 gate0 /int0 t0 crossbar
c8051f060/1/2/3/4/5/6/7 rev. 1.2 289 24.1.2. mode 1: 16-bit counter/timer mode 1 operation is the same as mode 0, except th at the counter/timer registers use all 16 bits. the counter/timers are enabled and configured in mode 1 in the same manner as for mode 0. 24.1.3. mode 2: 8-bit counter/timer with auto-reload mode 2 configures timer 0 or timer 1 to operate as 8-bit counter/timers with automatic reload of the start value. tl0 holds the count and th0 holds the reload value. when the counter in tl0 overflows from 0xff to 0x00, the timer overflow flag tf 0 (tcon.5) is set and the counter in tl0 is reloaded from th0. if timer 0 interrupts are enabled, an interrupt will occur when the tf0 flag is set. the reload value in th0 is not changed. tl0 must be initialized to the desired value before enabling the timer for the first count to be cor- rect. when in mode 2, timer 1 operates identically to timer 0. both counter/timers are enabled and configured in mode 2 in the same manner as mode 0. setting the tr0 bit (tcon.4) enables the timer when either gate0 (tmod.3) is logic 0 or when the input signal /int0 is low. figure 24.2. t0 mode 2 block diagram tclk tmod t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 tcon tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt tl0 (8 bits) reload th0 (8 bits) 0 1 0 1 sysclk pre-scaled clock ckcon s c a 0 s c a 1 t 1 m t 0 m tr0 gate0 /int0 t0 crossbar
c8051f060/1/2/3/4/5/6/7 290 rev. 1.2 24.1.4. mode 3: two 8-bit counter/timers (timer 0 only) in mode 3, timer 0 is configured as two separate 8-bit counter/timers held in tl0 and th0. the counter/ timer in tl0 is controlled using the timer 0 control/status bits in tcon and tmod: tr0, c/t0, gate0 and tf0. tl0 can use eit her the system clock or an external input si gnal as its timebase. the th0 register is restricted to a timer function sourced by the system clock or prescaled clock. th0 is enabled using the timer 1 run control bit tr1. th0 sets the timer 1 over flow flag tf1 on overflow and thus controls the timer 1 interrupt. timer 1 is inactive in mode 3. when timer 0 is operat ing in mode 3, timer 1 can be operated in modes 0, 1 or 2, but cannot be clocked by external signals nor set the tf1 flag and generate an interrupt. however, the timer 1 overflow can be used to generate baud ra tes for the smbus and/or uart, and/or initiate adc conversions. while timer 0 is operating in mode 3, timer 1 run control is handled through its mode set- tings. to run timer 1 while timer 0 is in mode 3, set the timer 1 mode as 0, 1, or 2. to disable timer 1, configure it for mode 3. figure 24.3. t0 mode 3 block diagram tl0 (8 bits) tmod 0 1 tcon tf0 tr0 tr1 tf1 ie1 it1 ie0 it0 interrupt interrupt 0 1 sysclk pre-scaled clock tr1 th0 (8 bits) ckcon s c a 0 s c a 1 t 1 m t 0 m t 1 m 1 t 1 m 0 c / t 1 g a t e 1 g a t e 0 c / t 0 t 0 m 1 t 0 m 0 tr0 gate0 /int0 t0 crossbar
c8051f060/1/2/3/4/5/6/7 rev. 1.2 291 figure 24.4. tcon: timer control register bit7: tf1: timer 1 overflow flag. set by hardware when timer 1 overflows. this flag can be cleared by software but is auto- matically cleared when the cpu vectors to the timer 1 interrupt service routine. 0: no timer 1 overflow detected. 1: timer 1 has overflowed. bit6: tr1: timer 1 run control. 0: timer 1 disabled. 1: timer 1 enabled. bit5: tf0: timer 0 overflow flag. set by hardware when timer 0 overflows. this flag can be cleared by software but is auto- matically cleared when the cpu vectors to the timer 0 interrupt service routine. 0: no timer 0 overflow detected. 1: timer 0 has overflowed. bit4: tr0: timer 0 run control. 0: timer 0 disabled. 1: timer 0 enabled. bit3: ie1: external interrupt 1. this flag is set by hardware when an edge/level of type defined by it1 is detected. it can be cleared by software but is automatically cleared when the cpu vectors to the external inter- rupt 1 service routine if it1 = 1. this flag is the inverse of the /int1 signal. bit2: it1: interrupt 1 type select. this bit selects whether t he configured /int1 interrupt will be falling-edge sensitive or active-low. 0: /int1 is level triggered, active-low. 1: /int1 is edge tr iggered, falling-edge. bit1: ie0: external interrupt 0. this flag is set by hardware when an edge/level of type defined by it0 is detected. it can be cleared by software but is automatically cleared when the cpu vectors to the external inter- rupt 0 service routine if it0 = 1. this flag is the inverse of the /int0 signal. bit0: it0: interrupt 0 type select. this bit selects whether t he configured /int0 interrupt will be falling-edge sensitive or active-low. 0: /int0 is level trigge red, active logic-low. 1: /int0 is edge tr iggered, falling-edge. r/w r/w r/w r/w r/w r/w r/w r/w reset value tf1 tr1 tf0 tr0 ie1 it1 ie0 it0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: sfr page: 0x88 0
c8051f060/1/2/3/4/5/6/7 292 rev. 1.2 figure 24.5. tmod: timer mode register bit7: gate1: timer 1 gate control. 0: timer 1 enabled when tr1 = 1 irrespective of /int1 logic level. 1: timer 1 enabled only when tr1 = 1 and /int1 = logic 1. bit6: c/t1: counter/timer 1 select. 0: timer function: timer 1 incremented by clock defined by t1m bit (ckcon.4). 1: counter function: timer 1 incremented by high-to-low transitions on external input pin (t1). bits5-4: t1m1-t1m0: timer 1 mode select. these bits select the timer 1 operation mode. bit3: gate0: timer 0 gate control. 0: timer 0 enabled when tr0 = 1 irrespective of /int0 logic level. 1: timer 0 enabled only when tr0 = 1 and /int0 = logic 1. bit2: c/t0: counter/timer select. 0: timer function: timer 0 incremented by clock defined by t0m bit (ckcon.3). 1: counter function: timer 0 incremented by high-to-low transitions on external input pin (t0). bits1-0: t0m1-t0m0: timer 0 mode select. these bits select the timer 0 operation mode. r/w r/w r/w r/w r/w r/w r/w r/w reset value gate1 c/t1 t1m1 t1m0 gate0 c/t0 t0m1 t0m0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x89 0 t1m1 t1m0 mode 0 0 mode 0: 13-bit counter/timer 0 1 mode 1: 16-bit counter/timer 10 mode 2: 8-bit counter/timer with auto- reload 1 1 mode 3: timer 1 inactive t0m1 t0m0 mode 0 0 mode 0: 13-bit counter/timer 0 1 mode 1: 16-bit counter/timer 10 mode 2: 8-bit counter/timer with auto- reload 1 1 mode 3: two 8-bit counter/timers
c8051f060/1/2/3/4/5/6/7 rev. 1.2 293 figure 24.6. ckcon: clock control register bits7-5: unused. read = 000b, write = don?t care. bit4: t1m: timer 1 clock select. this select the clock source su pplied to timer 1. t1m is ignore d when c/t1 is set to logic 1. 0: timer 1 uses the clock defined by the prescale bits, sca1-sca0. 1: timer 1 uses the system clock. bit3: t0m: timer 0 clock select. this bit selects the clock source supplied to timer 0. t0m is ignored when c/t0 is set to logic 1. 0: counter/timer 0 uses the clock defined by the prescale bits, sca1-sca0. 1: counter/timer 0 uses the system clock. bit2: unused. read = 0b, write = don?t care. bits1-0: sca1-sca0: ti mer 0/1 prescale bits these bits control the division of the clock su pplied to timer 0 and/or timer 1 if configured to use prescaled clock inputs. ?note: external clock divided by 8 is synchronized with the system clock, and external clock must be less than or equal to the system clock frequency to operate the timer in this mode. r/w r/w r/w r/w r/w r/w r/w r/w reset value - - - t1m t0m - sca1 sca0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8e 0 sca1 sca0 prescaled clock 0 0 system clock divided by 12 0 1 system clock divided by 4 1 0 system clock divided by 48 1 1 external clock divided by 8?
c8051f060/1/2/3/4/5/6/7 294 rev. 1.2 figure 24.7. tl0: timer 0 low byte bits 7-0: tl0: timer 0 low byte. the tl0 register is the low byte of the 16-bit timer 0 r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8a 0 figure 24.8. tl1: timer 1 low byte bits 7-0: tl1: timer 1 low byte. the tl1 register is the low byte of the 16-bit timer 1. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8b 0 figure 24.9. th0: timer 0 high byte bits 7-0: th0: timer 0 high byte. the th0 register is the high byte of the 16-bit timer 0. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8c 0 figure 24.10. th1: timer 1 high byte bits 7-0: th1: timer 1 high byte. the th1 register is the high byte of the 16-bit timer 1. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0x8d 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 295 24.2. timer 2, timer 3, and timer 4 timers 2, 3, and 4 are 16-bit counter/timers, each formed by two 8-bit sfrs: tmrnl (low byte) and tmrnh (high byte) where n = 2, 3, and 4 for timers 2, 3, and 4 respectively. these timers feature auto- reload, capture, and togg le output modes with the ability to count up or down. captur e mode and auto- reload mode are selected using bits in the timer 2, 3, and 4 control registers (tmrncn). toggle output mode is selected using the timer 2, 3, and 4 configuration registers (tmrncf). these timers may also be used to generate a square-wave at an external pin. timers 2, 3, and 4 can use either the system clock (divided by one, two, or twelve), external clock (divi ded by eight) or transitions on an external input pin as its clock source. timer 2 and 3 can be used to start an adc data conversion and timers 2, 3, and 4 can schedule dac outputs. timers 1, 2, 3, or 4 may be used to generate baud rate s for uart 0. only timer 1 can be used to generate baud rates for uart 1. the counter/timer select bit c/tn bit (tmrncn.1) conf igures the peripheral as a counter or timer. clear- ing c/tn configures the timer to be in a timer mode (i .e., the selected timer clock source as the input for the timer). when c/tn is set to 1, the timer is configured as a counter (i.e., high-to-low transitions at the tn input pin increment (or decrement) the counter/timer register. refer to section ?18.1. ports 0 through 3 and the priority crossbar decoder? on page 205 for information on selecting and configuring external i/o pins for digital peripherals, such as the tn pin. timer 2, 3, and 4 can use either sysclk, sysclk divide d by 2, sysclk divided by 12, an external clock divided by 8, or high-to-low transitions on the tn input pin as its clock source when operating in counter/ timer with capture mode. clearing the c/tn bit (tncon.1) selects the system clock/external clock as the input for the timer. the timer clock select bits tnm0 and tnm1 in tmrncf can be used to select the sys- tem clock undivided, system clock divided by two, syst em clock divided by 12, or an external clock pro- vided at the xtal1/xtal2 pins divi ded by 8 (see figure 24.14). when c/tn is set to logic 1, a high-to-low transition at the tn input pin increments the counte r/timer register (i.e., co nfigured as a counter). 24.2.1. configuring timer 2, 3, and 4 to count down timers 2, 3, and 4 have the abilit y to count down. when the timer?s respective decrement enable bit (dcenn) in the timer configuration register (see fi gure 24.14) is set to ?1?, the timer can then count up or down . when dcenn = 1, the direction of the timer?s coun t is controlled by the tnex pin?s logic level. when tnex = 1, the counter/timer will count up; when tnex = 0, the counter/timer will count down. to use this feature, tnex must be enabled in the digital crossbar and configured as a digital input. note: when dcenn = 1, other functions of the tnex input (i.e., capture and auto-reload) are not available. tnex will only control the di rection of the timer when dcenn = 1.
c8051f060/1/2/3/4/5/6/7 296 rev. 1.2 24.2.2. capture mode in capture mode, timer 2, 3, and 4 will operate as a 16-bit counter/time r with capture facility. when the timer external enable bit (found in the tmrncn register ) is set to ?1?, a high-to-low transition on the tnex input pin causes the 16-bit value in the associated ti mer (thn, tln) to be loaded into the capture registers (rcapnh, rcapnl). if a capture is triggered in the counter/timer, the timer external flag (tmrncn.6) will be set to ?1? and an interrupt will o ccur if the interrupt is enabled. see section ?13.3. interrupt handler? on page 151 for further information concerning the configuration of interrupt sources. as the 16-bit timer register increments and overfl ows tmrnh:tmrnl, the tfn timer overflow/underflow flag (tmrncn.7) is set to ?1? and an interrupt will occur if t he interrupt is enabled. th e timer can be config- ured to count down by setting th e decrement enable bit (tmrncf.0) to ?1?. this will cause the timer to decrement with every timer clock/count event and underflow when the timer transitions from 0x0000 to 0xffff. just as in overflows, the overflow/underflow flag (tfn) will be set to ?1?, and an interrupt will occur if enabled. counter/timer with capture mode is selected by setting the capture/reload select bit cp/rln (tmrncn.0) and the timer 2, 3, and 4 run control bit trn (tncon.2) to logic 1. the timer 2, 3, and 4 respective external enable exenn (tncon .3) must also be set to logic 1 to enable a captures. if exenn is cleared, transition s on tnex will be ignored. tmrnl tmrnh trn tclk interrupt tmrncn exfn exenn trn c/tn cp/rln tfn sysclk 12 2 tmrncf d c e n t n o e t o g n t n m 1 t n m 0 toggle logic tn (port pin) 0 1 1 0 exenn crossbar tnex rcapnl rcapnh 0xff 0xff 8 external clock (xtal1) tn crossbar ovf capture figure 24.11. t2, 3, and 4 capture mode block diagram
c8051f060/1/2/3/4/5/6/7 rev. 1.2 297 24.2.3. auto-reload mode in auto-reload mode, the counter/timer can be configured to count up or down and cause an interrupt/flag to occur upon an overflow/underflow event. when counting up, the coun ter/timer will set its overflow/under- flow flag (tfn) and cause an interrupt (if enabled) upon overflow/underflow, and the values in the reload/ capture registers (rcapnh and rcapnl) are loaded into the timer and the timer is restarted. when the timer external enable bit (exenn) bit is set to ?1? and the decrem ent enable bit (dcenn) is ?0?, a falling edge (?1?-to-?0? transition) on the tnex pin (configured as an input in the digital crossbar) will cause a timer reload (in addition to timer overflows causing auto-rel oads). when dcenn is set to ?1?, the state of the tnex pin controls whether the counter/timer counts up (increments) or down (decrements), and will not cause an auto-reload or interrupt event. see section 24.2.1 for information concerning configuration of a timer to count down. when counting down, the c ounter/timer will set its overflow/underflow flag (tfn) and cause an interrupt (if enabled) when the value in the timer (tmrnh and tm rnl registers) matches the 16-bit value in the reload/capture registers (rcapnh an d rcapnl). this is considered an underflow event, and will cause the timer to load the value 0xffff. the timer is automatically restarted wh en an underflow occurs. counter/timer with auto-reload mode is selected by clearing the cp/rln bit. setting trn to logic 1 enables and starts the timer. in auto-reload mode, the external flag (exfn) togg les upon every overflow or underflow and does not cause an interrupt. the exfn flag can be thought of as the most significant bit (msb) of a 17-bit counter. . tmrnl tmrnh trn tclk reload interrupt exenn crossbar tnex tmrncn exfn exenn trn c/tn cp/rln tfn sysclk 12 2 tmrncf d c e n t n o e t o g n t n m 1 t n m 0 toggle logic tn (port pin) 0 1 1 0 rcapnl rcapnh 0xff 0xff ovf 8 external clock (xtal1) tn crossbar smbus (timer 4 only) figure 24.12. t2, 3, and 4 auto-reload mode block diagram
c8051f060/1/2/3/4/5/6/7 298 rev. 1.2 24.2.4. toggle output mode timer 2, 3, and 4 have the capability to toggle the state of their respective output port pins (t2, t3, or t4) to produce a 50% duty cycle wave form output. the po rt pin state will change upon the overflow or under- flow of the respective timer (dependi ng on whether the timer is counting up or down ). the toggle frequency is determined by the clock source of the timer and the values loaded into rcapnh and rcapnl. when counting down, the auto-rel oad value for the timer is 0xffff, and under flow will occur when the value in the timer matches the value stored in rcapnh:rcapnl. when counting up, the auto-reload value for the timer is rcapnh:rcapnl, and overflow will occur when the value in th e timer transitions from 0xffff to the reload value. to output a square wave, the timer is placed in reload mode (the capture/reload select bit in tmrncn and the timer/counter select bit in tmrncn are cleared to ?0?). the timer output is enabled by setting the timer output enable bit in tmrncf to ?1?. the time r should be configured via the timer clock source and reload/underflow values such that the timer overflow/u nderflows at 1/2 the desire d output frequency. the port pin assigned by the crossbar as the timer?s output pin should be configured as a digital output (see section ?18. port input/output? on page 203 ). setting the timer?s run bit (t rn) to ?1? will start the toggle of the pin. a read/write of the timer?s toggle output stat e bit (tmrncf.2) is used to read the state of the toggle output, or to force a value of the output. this is useful when it is desired to start the toggle of a pin in a known state, or to force the pin into a desired state when the toggle mode is halted. f sq f tclk 265536 rcapn ? () ? --------------------------- ------------------------- - = equation 24.1. toggle mode square wave frequency
c8051f060/1/2/3/4/5/6/7 rev. 1.2 299 bit7: tfn: timer 2, 3, and 4 overflow/underflow flag. set by hardware when either the timer overfl ows from 0xffff to 0x0000, underflows from the value placed in rcapnh:rcapnl to 0xffff (in auto-reload mode), or underflows from 0x0000 to 0xffff (in capture mode). when the timer interrupt is enabled, setting this bit causes the cpu to vector to the timer interrupt service rout ine. this bit is not automatically cleared by hardware and must be cleared by software. bit6: exfn: timer 2, 3, and 4 external flag. set by hardware when either a capture or rel oad is caused by a high-to-low transition on the tnex input pin and exenn is logic 1 . when the timer interrupt is enabled, sett ing this bit causes the cpu to vector to the timer interrupt service routine. this bi t is not automatically cleared by hardware and must be cleared by software. bit5-4: reserved. bit3: exenn: timer 2, 3, and 4 external enable. enables high-to-low transitions on tnex to trigger captures, reloads, and control the direc- tion of the timer/coun ter (up or down count). if dcenn = 1, tnex will determ ine if the timer counts up or down when in auto-reload mode. if exenn = 1, tn ex should be configured as a digital input. 0: transitions on the tnex pin are ignored. 1: transitions on the tnex pin cause capture, re load, or control the direction of timer count (up or down) as follows: capture mode : ?1?-to-?0? transition on tnex pin ca uses rcapnh:rcapnl to capture timer value. auto-reload mode : dcenn = 0: ?1?-to-?0? transition causes re load of timer and sets the exfn flag. dcenn = 1: tnex logic level controls direction of timer (up or down). bit2: trn: timer 2, 3, and 4 run control. this bit enables/disables the respective timer. 0: timer disabled. 1: timer enabled and running/counting. bit1: c/tn: counter/timer select. 0: timer function: timer incremented by clock defined by tnm1:tnm0 (tmrncf.4:tmrncf.3). 1: counter function: timer incremented by hi gh-to-low transitions on external input pin. bit0: cp/rln: capture/reload select. this bit selects whether the timer functions in capture or auto-reload mode. 0: timer is in auto-reload mode. 1: timer is in capture mode. r/w r/w r/w r/w r/w r/w r/w r/w reset value tfn exfn - - exenn trn c/tn cp/rln 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 bit addressable sfr address: tmr2cn: 0xc8; tmr3cn: 0xc8; tmr4cn: 0xc8 sfr page: tmr2cn: page 0; tmr3cn: page 1; tmr4cn: page 2 figure 24.13. tmrncn: timer 2, 3, and 4 control registers
c8051f060/1/2/3/4/5/6/7 300 rev. 1.2 bit7-5: reserved. bit4-3: tnm1 and tnm0: timer clock mode select bits. bits used to select the timer clock sour ce. the sources can be the system clock (sysclk), sysclk divided by 2 or 12, or an exte rnal clock signal rout ed to tn (port pin) divided by 8. clock source is selected as follows: 00: sysclk/12 01: sysclk 10: external clock/8 11: sysclk/2 bit2: togn: toggle output state bit. when timer is used to toggle a port pin, this bi t can be used to read the state of the output, or can be written to in order to force the state of the output. bit1: tnoe: timer output enable bit. this bit enables the timer to output a 50% duty cycle output to the timer?s assigned external port pin. note : a timer is configured for square wave output as follows: cp/rln = 0 c/tn = 0 tnoe = 1 load rcapnh:rcapnl (see ?toggle mode square wave frequency? on page 298.) configure port pin to output squarewave (see section ?18. port input/output? on page 203 ) 0: output of toggle mode not available at timers?s assigned port pin. 1: output of toggle mode available at timers?s assigned port pin. bit0: dcenn: decrement enable bit. this bit enables the timer to count up or down as determined by the state of tnex. 0: timer will count up, regard less of the state of tnex. 1: timer will count up or down dependin g on the state of tnex as follows: if tnex = 0, the timer counts down if tnex = 1, the timer counts up. r/w r/w r/w r/w r/w reset value - - - tnm1 tnm0 togn tnoe dcenn 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: tmr2cf: 0xc9; tmr3cf: 0xc9; tmr4cf: 0xc9 sfr page tmr2cf: page 0; tmr3cf: page 1; tmr4cf: page 2 figure 24.14. tmrncf: timer 2, 3, and 4 configuration registers
c8051f060/1/2/3/4/5/6/7 rev. 1.2 301 bits 7-0: rcap2, 3, and 4l: timer 2, 3, and 4 capture register low byte. the rcap2, 3, and 4l register captures the low byte of timer 2, 3, and 4 when timer 2, 3, and 4 is configured in capture mode. when timer 2, 3, and 4 is configured in auto-reload mode, it holds the low byte of the reload value. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: rcap2l: 0xca; rcap3l: 0xca; rcap4l: 0xca sfr page: rcap2l: page 0; rcap3l: page 1; rcap4l: page 2 figure 24.15. rcapnl: timer 2, 3, and 4 capture register low byte figure 24.16. rcapnh: timer 2, 3, and 4 capture register high byte bits 7-0: rcap2, 3, and 4h: timer 2, 3, and 4 capture register high byte. the rcap2, 3, and 4h register captures the high byte of timer 2, 3, and 4 when timer 2, 3, and 4 is configured in capture mode. when timer 2, 3, and 4 is configured in auto-reload mode, it holds the high by te of the reload value. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: rcap2h: 0xcb; rcap3h: 0xcb; rcap4h: 0xcb sfr page: rcap2h: page 0; rcap3h: page 1; rcap4h: page 2 figure 24.17. tmrnl: timer 2, 3, and 4 low byte bits 7-0: tl2, 3, and 4: timer 2, 3, and 4 low byte. the tl2, 3, and 4 register contains the low byte of the 16-bit timer 2, 3, and 4 r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: tmr2l: 0xcc; tmr3l: 0xcc; tmr4l: 0xcc sfr page: tmr2l: page 0; tmr3l: page 1; tmr4l: page 2
c8051f060/1/2/3/4/5/6/7 302 rev. 1.2 figure 24.18. tmrnh: timer 2, 3, and 4 high byte bits 7-0: th2, 3, and 4: timer 2, 3, and 4 high byte. the th2, 3, and 4 register contains the hi gh byte of the 16-bit timer 2, 3, and 4 r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: tmr2h: 0xcd; tmr3h: 0xcd; tmr4h: 0xcd sfr page: tmr2h: page 0; tmr3h: page 1; tmr4h: page 2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 303 25. programmable counter array the programmable counter array (pca0) provides enhanced timer functionality while requiring less cpu intervention than the standard 8051 counter/timers. pc a0 consists of a dedicated 16-bit counter/timer and six 16-bit capture/compare modules. each capture/compare module has its own associated i/o line (cexn) which is routed through the crossbar to port i/o when enabled (see section ?18.1. ports 0 through 3 and the priority crossbar decoder? on page 205 ). the counter/timer is driven by a programmable time- base that can select between six inputs as its sour ce: system clock, system clock divided by four, system clock divided by twelve, the external oscillator clock source divided by 8, timer 0 overflow, or an external clock signal on the eci line. each capture/compare module may be configured to operate independently in one of six modes: edge-triggered capture, software timer, high-speed output, frequency output, 8-bit pwm, or 16-bit pwm (each is described in section 25.2 ). the pca is configured and controlled through the system controller's special function registers. the basic pca block diagram is shown in figure 25.1. figure 25.1. pca block diagram capture/compare module 1 capture/compare module 0 capture/compare module 2 capture/compare module 3 cex1 eci crossbar cex2 cex3 cex0 port i/o 16-bit counter/timer pca clock mux sysclk/12 sysclk/4 timer 0 overflow eci sysclk external clock/8 capture/compare module 4 cex4 capture/compare module 5 cex5
c8051f060/1/2/3/4/5/6/7 304 rev. 1.2 25.1. pca counter/timer the 16-bit pca counter/timer consists of two 8-bi t sfrs: pca0l and pca0h. pca0h is the high byte (msb) of the 16-bit counter/timer and pca0l is the lo w byte (lsb). reading pc a0l automatically latches the value of pca0h into a ?snapshot? register; the following pca0h read accesses this ?snapshot? register. reading the pca0l register first guarantees an accu rate reading of the entire 16-bit pca0 counter. read- ing pca0h or pca0l does not disturb the counter operation. the cps2-cps0 bits in the pca0md regis- ter select the timebase for the counter/timer as shown in table 25.1. when the counter/timer overflows from 0xffff to 0x0 000, the counter overflow flag (cf) in pca0md is set to logic 1 and an interrupt request is generated if cf interrupts are enabled. setting the ecf bit in pca0md to logic 1 enables the cf flag to generate an interrupt request. the cf bit is not automatically cleared by hardware when the cpu vectors to the inte rrupt service routine, and must be cleared by soft- ware (note: pca0 interrupts must be globally enabled before cf interrupts are recognized. pca0 inter- rupts are globally enabled by setting the ea bit (ie.7) and the epca0 bit in eie1 to logic 1). clearing the cidl bit in the pca0md register a llows the pca to continue normal operation while the cpu is in idle mode. table 25.1. pca timebase input options cps2 cps1 cps0 timebase 0 0 0 system clock divided by 12 0 0 1 system clock divided by 4 0 1 0 timer 0 overflow 011 high-to-low transitions on eci (max rate = system clock divided by 4) 100system clock 101 external oscillator source divid ed by 8 (synchronized with sys- tem clock) figure 25.2. pca counter/ timer block diagram pca0md c i d l w d t e e c f c p s 1 c p s 0 w d l c k c p s 2 idle 0 1 pca0h pca0l snapshot register to sfr bus overflow to pca interrupt system cf pca0l read to pca modules sysclk/12 sysclk/4 timer 0 overflow eci 000 001 010 011 100 101 sysclk external clock/8 pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3
c8051f060/1/2/3/4/5/6/7 rev. 1.2 305 25.2. capture/compare modules each module can be configured to operate independently in one of six operation modes: edge-triggered capture, software timer, high speed output, frequency output, 8-bit pulse width modulator, or 16-bit pulse width modulator. each module has special func tion registers (sfrs) asso ciated with it in the cip- 51 system controller. these registers are used to exchange data with a module and configure the module's mode of operation. table 25.2 summarizes the bit settings in the pca0cp mn registers used to select the pca0 capture/com- pare module?s operating modes. setting the eccfn bi t in a pca0cpmn register enables the module's ccfn interrupt. note: pca0 interrupts must be globally enabled before individual ccfn interrupts are rec- ognized. pca0 interrupts are globally enabled by se tting the ea bit (ie.7) and the epca0 bit (eie1.3) to logic 1. see figure 25.3 for details on the pca interrupt configuration. table 25.2. pca0cpm register settings for pca capture/compare modules pwm16 ecom capp capn mat tog pwm eccf operation mode x x 1 0 000x capture triggered by positive edge on cexn x x 0 1 000x capture triggered by negative edge on cexn x x 1 1 000x capture triggered by transition on cexn x 1 0 0 1 0 0 x software timer x 1 0 0 1 1 0 x high speed output x 1 0 0 0 1 1 x frequency output 0 1 0 0 0 0 1 0 8-bit pulse width modulator 1 1 0 0 0 0 1 0 16-bit pulse width modulator x = don?t care figure 25.3. pca interru pt block diagram pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3 pca0md c i d l e c f c p s 1 c p s 0 c p s 2 0 1 pca module 0 pca module 1 eccf1 0 1 eccf0 0 1 pca module 2 eccf2 0 1 pca module 3 eccf3 eccf4 pca counter/ timer overflow 0 1 interrupt priority decoder epca0 (eie.3) pca0cpmn (for n = 0 to 5) p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 0 1 pca module 4 0 1 pca module 5 0 1 ea (ie.7) 0 1 eccf5
c8051f060/1/2/3/4/5/6/7 306 rev. 1.2 25.2.1. edge-triggered capture mode in this mode, a valid transition on the cexn pin caus es pca0 to capture the value of the pca0 counter/ timer and load it into the corresponding module's 16-bit capture/compare register (pca0cpln and pca0cphn). the cappn and capnn bits in the pca0cpmn register are used to select the type of transi- tion that triggers the capture: low-to-high transition (p ositive edge), high-to-low transition (negative edge), or either transition (positive or negative edge). when a capture occurs, the capture/compare flag (ccfn) in pca0cn is set to logic 1 and an interrupt request is generated if ccf interrupts are enabled. the ccfn bit is not automatically cleared by hardware when th e cpu vectors to the interrupt serv ice routine, and must be cleared by software. note: the signal at cexn must be high or low for at least 2 system clock cycles in order to be valid. figure 25.4. pca capture mode diagram pca0l pca0cpln pca timebase cexn crossbar port i/o pca0h capture pca0cphn 0 1 0 1 (to ccfn) pca interrupt pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3
c8051f060/1/2/3/4/5/6/7 rev. 1.2 307 25.2.2. software timer (compare) mode in software timer mode, the pca0 counter/timer is compared to the module's 16-bit capture/compare reg- ister (pca0cphn and pca0cpln). when a match oc curs, the capture/compare flag (ccfn) in pca0cn is set to logic 1 and an interrupt request is generated if ccf interrupts are enabled. the ccfn bit is not automatically cleared by hardware when the cpu vect ors to the interrupt service routine, and must be cleared by software. setting the ecomn and matn bits in the pca0cpmn register enables software timer mode. important note about capture/compare registers : when writing a 16-bit value to the pca0 capture/ compare registers, the low byte should always be wri tten first. writing to pca0cpln clears the ecomn bit to ?0?; writing to pca0cp hn sets ecomn to ?1?. figure 25.5. pca software timer mode diagram match 16-bit comparator pca0h pca0cphn enable pca0l pca timebase pca0cpln 00 00 pca interrupt 0 1 x enb enb 0 1 write to pca0cpln write to pca0cphn reset pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n x pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3
c8051f060/1/2/3/4/5/6/7 308 rev. 1.2 25.2.3. high speed output mode in high speed output mode, a module?s associated cexn pin is toggled each time a match occurs between the pca counter and the module's 16- bit capture/compare register (pca0cphn and pca0cpln) setting the togn, matn, and ecomn bits in the pca0cpmn register enables the high- speed output mode. important note about capture/compare registers : when writing a 16-bit value to the pca0 capture/ compare registers, the low byte should always be wri tten first. writing to pca0cpln clears the ecomn bit to ?0?; writing to pca0 cphn sets ecomn to ?1?. figure 25.6. pca high speed output mode diagram match 16-bit comparator pca0h pca0cphn enable pca0l pca timebase pca0cpln pca interrupt 0 1 00 0x enb enb 0 1 write to pca0cpln write to pca0cphn reset pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n x cexn crossbar port i/o toggle 0 1 togn pca0cn c f c r c c f 0 c c f 2 c c f 1 c c f 5 c c f 4 c c f 3
c8051f060/1/2/3/4/5/6/7 rev. 1.2 309 25.2.4. frequency output mode frequency output mode produces a programmable-freq uency square wave on the module?s associated cexn pin. the capture/compare module high byte holds the number of pca clocks to count before the out- put is toggled. the frequency of the square wave is then defined by equation 25.1. where f pca is the frequency of the clock selected by the cps2-0 bits in the pca mode register, pca0md. the lower byte of the capture/compare module is compared to the pca0 counter low byte; on a match, cexn is toggled and the offset held in the high byte is added to the matched value in pca0cpln. fre- quency output mode is enabled by setting the ecom n, togn, and pwmn bits in the pca0cpmn register. important note about capture/compare registers : when writing a 16-bit value to the pca0 capture/ compare registers, the low byte should always be wri tten first. writing to pca0cpln clears the ecomn bit to ?0?; writing to pca0 cphn sets ecomn to ?1?. equation 25.1. square wave frequency output f sqr f pca 2 pca 0 cphn --------------------- ------------------- - = note: a value of 0x00 in the pca0cphn re gister is equal to 256 for this equation. 8-bit comparator pca0l enable pca timebase 000 0 match pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 0 pca0cphn 8-bit adder pca0cpln adder enable cexn crossbar port i/o toggle 0 1 togn 1 figure 25.7. pca frequency output mode
c8051f060/1/2/3/4/5/6/7 310 rev. 1.2 25.2.5. 8-bit pulse width modulator mode each module can be used independently to generate pulse width modulated (pwm) outputs on its associ- ated cexn pin. the frequency of th e output is dependent on the timebase for the pca0 counter/timer. the duty cycle of the pwm output signal is varied using the module's pca0cpln capture/compare register. when the value in the low byte of the pca0 counter /timer (pca0l) is equal to the value in pca0cpln, the output on the cexn pin will be high . when the count value in pca0l overflows, the cexn output will be low (see figure 25.8). also, when the counter/timer low byte (pca0l) overflows from 0xff to 0x00, pca0cpln is reloaded automatically with the value stor ed in the counter/timer's high byte (pca0h) with- out software intervention. setting the ecomn and pw mn bits in the pca0cpmn register enables 8-bit pulse width modulator mode. the duty cycle for 8-bit pwm mode is given by equation 25.2. important note about capture/compare registers : when writing a 16-bit value to the pca0 capture/ compare registers, the low byte should always be wri tten first. writing to pca0cpln clears the ecomn bit to ?0?; writing to pca0 cphn sets ecomn to ?1?. dutycycle 256 pca 0 cphn ? () 256 ------------------ ----------------- ---------------- = equation 25.2. 8-bit pwm duty cycle 8-bit comparator pca0l pca0cpln pca0cphn cexn crossbar port i/o enable overflow pca timebase 0000 0 q q set clr s r match pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 0 figure 25.8. pca 8-bit pwm mode diagram
c8051f060/1/2/3/4/5/6/7 rev. 1.2 311 25.2.6. 16-bit pulse width modulator mode each pca0 module may also be operated in 16-bit pwm mode. in this mode, the 16-bit capture/compare module defines the number of pca0 clocks for the low time of the pwm signal. when the pca0 counter matches the module contents, the output on cexn is as serted high; when the counter overflows, cexn is asserted low. to output a varying duty cycle, new value writes should be synchronized with pca0 ccfn match interrupts. 16-bit pwm mode is enabled by setting the ecomn, pwmn, and pwm16n bits in the pca0cpmn register. for a varying duty cycle, ccfn should also be set to logic 1 to enable match inter- rupts. the duty cycle for 16-bit pwm mode is given by equation 25.3. important note about capture/compare registers : when writing a 16-bit value to the pca0 capture/ compare registers, the low byte should always be wri tten first. writing to pca0cpln clears the ecomn bit to ?0?; writing to pca0 cphn sets ecomn to ?1?. equation 25.3. 16-bit pwm duty cycle dutycycle 65536 pca 0 cpn ? () 65536 ------------------ ------------------ ---------------- - = figure 25.9. pca 16-bit pwm mode pca0cpln pca0cphn enable pca timebase 0000 0 pca0cpmn p w m 1 6 n e c o m n e c c f n t o g n p w m n c a p p n c a p n n m a t n 1 16-bit comparator cexn crossbar port i/o overflow q q set clr s r match pca0h pca0l
c8051f060/1/2/3/4/5/6/7 312 rev. 1.2 25.3. register descriptions for pca0 following are detailed descriptions of the special func tion registers related to the operation of pca0. bit7: cf: pca counter/timer overflow flag. set by hardware when the pca0 counter/timer overflows from 0xffff to 0x0000. when the counter/timer overflow (cf) interrupt is enabled, setting this bit causes the cpu to vec- tor to the cf interrupt service routine. this bit is not automatically cleared by hardware and must be cleared by software. bit6: cr: pca0 counter /timer run control. this bit enables/disables the pca0 counter/timer. 0: pca0 counter/timer disabled. 1: pca0 counter/timer enabled. bit5: ccf5: pca0 module 5 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled, setting this bit causes the cpu to vect or to the ccf interrupt service routine. this bit is not automatically cleared by hard ware and must be cleared by software. bit4: ccf4: pca0 module 4 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled, setting this bit causes the cpu to vect or to the ccf interrupt service routine. this bit is not automatically cleared by hard ware and must be cleared by software. bit3: ccf3: pca0 module 3 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled, setting this bit causes the cpu to vect or to the ccf interrupt service routine. this bit is not automatically cleared by hard ware and must be cleared by software. bit2: ccf2: pca0 module 2 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled, setting this bit causes the cpu to vect or to the ccf interrupt service routine. this bit is not automatically cleared by hard ware and must be cleared by software. bit1: ccf1: pca0 module 1 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled, setting this bit causes the cpu to vect or to the ccf interrupt service routine. this bit is not automatically cleared by hard ware and must be cleared by software. bit0: ccf0: pca0 module 0 capture/compare flag. this bit is set by hardware when a match or capture occurs. when the ccf interrupt is enabled, setting this bit causes the cpu to vect or to the ccf interrupt service routine. this bit is not automatically cleared by hard ware and must be cleared by software. r/w r/w r/w r/w r/w r/w r/w r/w reset value cf cr ccf5 ccf4 ccf3 ccf2 ccf1 ccf0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd8 0 figure 25.10. pca0cn: pca control register
c8051f060/1/2/3/4/5/6/7 rev. 1.2 313 figure 25.11. pca0md: pca0 mode register bit7: cidl: pca0 counter/timer idle control. specifies pca0 behavior when cpu is in idle mode. 0: pca0 continues to function normally wh ile the system controlle r is in idle mode. 1: pca0 operation is suspended while the system controller is in idle mode. bits6-4: unused. read = 000b, write = don't care. bits3-1: cps2-cps0: pca0 co unter/timer pulse select. these bits select the timebase source for th e pca0 counter bit0: ecf: pca counter/timer overflow interrupt enable. this bit sets the masking of the pca0 co unter/timer overflow (cf) interrupt. 0: disable the cf interrupt. 1: enable a pca0 counter/timer overflow in terrupt request when cf (pca0cn.7) is set. ?note: external clock divided by 8 is synchronize d with the system clock, and external clock must be less than or equal to the system clock frequency to operate in this mode. r/w r/w r/w r/w r/w r/w r/w r/w reset value cidl - - - cps2 cps1 cps0 ecf 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xd9 0 cps2 cps1 cps0 timebase 0 0 0 system clock divided by 12 0 0 1 system clock divided by 4 0 1 0 timer 0 overflow 011 high-to-low transitions on eci (max rate = system clock divided by 4) 1 0 0 system clock 1 0 1 external clock divided by 8? 1 1 0 reserved 1 1 1 reserved
c8051f060/1/2/3/4/5/6/7 314 rev. 1.2 figure 25.12. pca0cpmn: pca0 capture/compare mode registers bit7: pwm16n: 16-bit pulse width modulation enable. this bit selects 16-bit mode when pulse width modulation mode is enabled (pwmn = 1). 0: 8-bit pwm selected. 1: 16-bit pwm selected. bit6: ecomn: comparator function enable. this bit enables/disables the compar ator function for pca0 module n. 0: disabled. 1: enabled. bit5: cappn: capture positi ve function enable. this bit enables/disables the positive edge capture for pca0 module n. 0: disabled. 1: enabled. bit4: capnn: capture negative function enable. this bit enables/disables the negative edge capture for pca0 module n. 0: disabled. 1: enabled. bit3: matn: match function enable. this bit enables/disables the match function for pca0 module n. when enabled, matches of the pca0 counter with a module's capture/comp are register cause the ccfn bit in pca0md register to be set to logic 1. 0: disabled. 1: enabled. bit2: togn: toggle function enable. this bit enables/disables the toggle function for pca0 module n. when enabled, matches of the pca0 counter with a module's capture/comp are register cause the logic level on the cexn pin to toggle. if the pwmn bit is also set to logic 1, the module operates in frequency output mode. 0: disabled. 1: enabled. bit1: pwmn: pulse width modulation mode enable. this bit enables/disables the pwm function for pca0 module n. when enabled, a pulse width modulated signal is output on the cexn pin. 8-bit pwm is used if pwm16n is logic 0; 16-bit mode is used if pwm16n logic 1. if the togn bit is also set, the module operates in frequency output mode. 0: disabled. 1: enabled. bit0: eccfn: capture/compare flag interrupt enable. this bit sets the masking of the capture/compare flag (ccfn) interrupt. 0: disable ccfn interrupts. 1: enable a capture/compare flag interrupt request when ccfn is set. r/w r/w r/w r/w r/w r/w r/w r/w reset value pwm16n ecomn cappn capnn matn togn pwmn eccfn 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: pca0cpm0: 0xda, pca0cpm1: 0xdb, pca0cpm2: 0xdc, pca0cpm3: 0xdd, pca0cpm4: 0xde, pca0cpm5: 0xdf sfr page: pca0cpm0: page 0, pca0cpm1: page 0, pca0cpm2: page 0, pca0cpm3: 0, pca0cpm4: page 0, pca0cpm5: page 0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 315 bits 7-0: pca0l: pca0 counter/timer low byte. the pca0l register holds the low byte (l sb) of the 16-bit pca0 counter/timer. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xf9 0 fi gure 25 . 13 . pca0l : pca0 c oun t er /ti mer l ow b y t e bits 7-0: pca0h: pca0 counter/timer high byte. the pca0h register holds the high byte (msb) of the 16-bit pca0 counter/timer. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: sfr page: 0xfa 0 figure 25.14. pca0h: pca0 counter/timer high byte
c8051f060/1/2/3/4/5/6/7 316 rev. 1.2 figure 25.15. pca0cpln: pca0 capture module low byte \ bits7-0: pca0cpln: pca0 capture module low byte. the pca0cpln register holds the low byte (lsb) of the 16-bit capture module n. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: pca0cpl0: 0xfb, pca0cpl1: 0xfd, pca0cpl2: 0xe9 , pca0cpl3: 0xeb, pca0cpl4: 0xed, pca0cpl5: 0xe1 sfr page: pca0cpl0: page 0, pca0cpl1: page 0, pca0cpl2: page 0, pca0cpl3: page 0, pca0cpl4: page 0, pca0cpl5: page 0 bits7-0: pca0cphn: pca0 capture module high byte. the pca0cphn register holds the high byte (msb) of the 16-bit capture module n. r/w r/w r/w r/w r/w r/w r/w r/w reset value 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0 sfr address: pca0cph0: 0xfc, pca0cph1: 0xfd , pca0cph2: 0xea, pca0cph3: 0x ec, pca0cph4: 0xee, pca0cph5: 0xe2 sfr page: pca0cph0: page 0, pca0cph1: page 0, pca0cph2: page 0, pca0cph3: page 0, pca0cph4: page 0, pca0cph5: page 0 figure 25.16. pca0cphn: pca0 capture module high byte
c8051f060/1/2/3/4/5/6/7 rev. 1.2 317 26. jtag (ieee 1149.1) each mcu has an on-chip jtag interface and logic to support boundary scan for production and in-sys- tem testing, flash read/write operations, and non-int rusive in-circuit debug. th e jtag interf ace is fully compliant with the ieee 1149.1 specification. refer to this specification for detailed descriptions of the test interface and boundary-scan architec ture. access of the jtag instruction register (ir) and data regis- ters (dr) are as described in the test access port and operation of the ieee 1149.1 specification. the jtag interface is accessed via four dedica ted pins on the mcu: tck, tms, tdi, and tdo. through the 16-bit jtag instruction register (ir), any of the eight instructions shown in figure 26.1 can be commanded. there are three dr?s associated wit h jtag boundary-scan, and four associated with flash read/write operations on the mcu. figure 26.1. ir: jtag instruction register reset value 0x0000 bit15 bit0 ir value instruction description 0x0000 extest selects the boundary data register fo r control and observability of all device pins 0x0002 sample/ preload selects the boundary data register for observability and presetting the scan-path latches 0x0004 idcode selects device id register 0xffff bypass selects bypass data register 0x0082 flash control selects flashcon register to contro l how the interface logic responds to reads and writes to the flashdat register 0x0083 flash data selects flashdat register for reads and writes to the flash memory 0x0084 flash address selects flashadr register which holds the address of all flash read, write, and erase operations 0x0085 flash scale selects flashscl register which controls the flash one-shot timer and read-always enable
c8051f060/1/2/3/4/5/6/7 318 rev. 1.2 26.1. boundary scan the dr in the boundary scan path is a 126-bit shift register for the c8051f060/2/4/6 and a 118-bit shift register for the c8051f061/3/5/7. the boundary dr provides control and observability of all the device pins as well as the sfr bus and weak pullup feature via the extest and sample commands. table 26.1. boundary data register bit definitions (c8051f060/2/4/6) extest provides access to both capture and updat e actions, while sample only performs a capture. bit action target 0 capture reset enable from mcu update reset enable to /rst pin 1 capture reset input from /rst pin update not used 2 capture can rx output enable to pin update can rx output enable to pin 3 capture can rx input from pin update can rx output to pin 4 capture can tx output enable to pin update can tx output enable to pin 5 capture can tx input from pin update can tx output to pin 6 capture external clock from xtal1 pin update not used 7 capture weak pullup enable from mcu update weak pullup enable to port pins 8, 10, 12, 14, 16, 18, 20, 22 capture p0.n output enable from mcu (e.g. bit 8 = p0.0, bit 10 = p0.1, etc.) update p0.n output enable to pin (e.g. bit 8 = p0.0oe, bit 10 = p0.1oe, etc.) 9, 11, 13, 15, 17, 19, 21, 23 capture p0.n input from pin (e.g. bit 9 = p0.0, bit 11 = p0.1, etc.) update p0.n output to pin (e.g. bi t 9 = p0.0, bit 11 = p0.1, etc.) 24, 26, 28, 30, 32, 34, 36, 38 capture p1.n output enable from mcu (follows p0.n numbering scheme) update p1.n output enable to pin (follows p0.n numbering scheme) 25, 27, 29, 31, 33, 35, 37, 39 capture p1.n input from pin (follows p0.n numbering scheme) update p1.n output to pin (fo llows p0.n numbering scheme) 40, 42, 44, 46, 48, 50, 52, 54 capture p2.n output enable from mcu (follows p0.n numbering scheme) update p2.n output enable to pin (follows p0.n numbering scheme) 41, 43, 45, 47, 49, 51, 53, 55 capture p2.n input from pin (follows p0.n numbering scheme) update p2.n output to pin (fo llows p0.n numbering scheme) 56, 58, 60, 62, 64, 66, 68, 70 capture p3.n output enable from mcu (follows p0.n numbering scheme) update p3.n output enable to pin (follows p0.n numbering scheme) 57, 59, 61, 63, 65, 67, 69, 71 capture p3.n input from pin (follows p0.n numbering scheme) update p3.n output to pin (fo llows p0.n numbering scheme) 72, 74, 76 capture p4.5, p4.6, p4.7 (r espectively) output enable from mcu update p4.5, p4.6, p4.7 (respec tively) output enable to pin 73, 75, 77 capture p4.5, p4.6, p4.7 (respectively) input from pin update p4.5, p4.6, p4.7 (res pectively) output to pin 78, 80, 82, 84, 86, 88, 90, 92 capture p5.n output enable from mcu (follows p0.n numbering scheme) update p5.n output enable to pin (follows p0.n numbering scheme)
c8051f060/1/2/3/4/5/6/7 rev. 1.2 319 79, 81, 83, 85, 87, 89, 91, 93 capture p5.n input from pin (follows p0.n numbering scheme) update p5.n output to pin (fo llows p0.n numbering scheme) 94, 96, 98, 100, 102, 104, 106, 108 capture p6.n output enable from mcu (follows p0.n numbering scheme) update p6.n output enable to pin (follows p0.n numbering scheme) 95, 97, 99, 101, 103, 105, 107, 109 capture p6.n input from pin (follows p0.n numbering scheme) update p6.n output to pin (fo llows p0.n numbering scheme) 110, 112, 114, 116, 118, 120, 122, 124 capture p7.n output enable from mcu (follows p0.n numbering scheme) update p7.n output enable to pin (follows p0.n numbering scheme) 111, 113, 115, 117, 119, 121, 123, 125 capture p7.n input from pin (follows p0.n numbering scheme) update p7.n output to pin (fo llows p0.n numbering scheme) table 26.1. boundary data register bit de finitions (c8051f060/2/4/6) (continued) extest provides access to both capture and updat e actions, while sample only performs a capture. bit action target
c8051f060/1/2/3/4/5/6/7 320 rev. 1.2 table 26.2. boundary data register bit definitions (c8051f061/3/5/7) extest provides access to both capture and updat e actions, while sample only performs a capture. bit action target 0 capture not used update not used 1 capture not used update not used 2 capture can rx output enable to pin update can rx output enable to pin 3 capture can rx input from pin update can rx output to pin 4 capture can tx output enable to pin update can tx output enable to pin 5 capture can tx input from pin update can tx output to pin 6 capture external clock from xtal1 pin update not used 7 capture weak pullup enable from mcu update weak pullup enable to port pins 8, 10, 12, 14, 16, 18, 20, 22 capture p0.n output enable from mcu (e.g. bit 8 = p0.0, bit 10 = p0.1, etc.) update p0.n output enable to pin (e.g. bit 8 = p0.0oe, bit 10 = p0.1oe, etc.) 9, 11, 13, 15, 17, 19, 21, 23 capture p0.n input from pin (e.g. bit 9 = p0.0, bit 11 = p0.1, etc.) update p0.n output to pin (e.g. bi t 9 = p0.0, bit 11 = p0.1, etc.) 24, 26, 28, 30, 32, 34, 36, 38 capture p1.n output enable from mcu (follows p0.n numbering scheme) update p1.n output enable to pin (follows p0.n numbering scheme) 25, 27, 29, 31, 33, 35, 37, 39 capture p1.n input from pin (follows p0.n numbering scheme) update p1.n output to pin (fo llows p0.n numbering scheme) 40, 42, 44, 46, 48, 50, 52, 54 capture p2.n output enable from mcu (follows p0.n numbering scheme) update p2.n output enable to pin (follows p0.n numbering scheme) 41, 43, 45, 47, 49, 51, 53, 55 capture p2.n input from pin (follows p0.n numbering scheme) update p2.n output to pin (fo llows p0.n numbering scheme) 56, 58, 60, 62, 64, 66, 68, 70 capture p3.n output enable from mcu (follows p0.n numbering scheme) update p3.n output enable to pin (follows p0.n numbering scheme) 57, 59, 61, 63, 65, 67, 69, 71 capture p3.n input from pin (follows p0.n numbering scheme) update p3.n output to pin (fo llows p0.n numbering scheme) 72 capture reset enable from mcu update reset enable to /rst pin 73 capture reset input from /rst pin update not used 74, 76, 78, 80, 82, 84 capture p5.0, p5.1, p5.2, p5.3, p5.5, p5.7 (respecti vely) output enable from mcu? update p5.0, p5.1, p5 .2, p5.3, p5.5, p5.7 (respectively) output enable to pin? 75, 77, 79, 81, 83, 85 capture p5.0, p5.1, p5.2, p5.3, p5.5, p5.7 (respectively) input from pin? update p5.0, p5.1, p5 .2, p5.3, p5.5, p5.7 (respe ctively) output to pin? 86, 88, 90, 92, 94, 96, 98, 100 capture p6.n output enable from mcu (follows p0.n numbering scheme)? update p6.n output enable to pin (follows p0.n numbering scheme)?
c8051f060/1/2/3/4/5/6/7 rev. 1.2 321 26.1.1. extest instruction the extest instruction is accessed via the ir. the bo undary dr provides control and observability of all the device pins as well as the weak pullup feature. all inputs to on-chip logic are set to logic 1. 26.1.2. sample instruction the sample instruction is accessed via the ir. the boundary dr prov ides observability and presetting of the scan-path latches. 26.1.3. bypass instruction the bypass instruction is acce ssed via the ir. it provides access to the standard jtag bypass data reg- ister. 26.1.4. idcode instruction the idcode instruction is accessed via the ir. it provides access to the 32-bit device id register. 87, 89, 91, 93, 95, 97, 99, 101 capture p6.n input from pin (follows p0.n numbering scheme)? update p6.n output to pin (fo llows p0.n numbering scheme)? 102, 104, 106, 108, 110, 112, 114, 116 capture p7.n output enable from mcu (follows p0.n numbering scheme)? update p7.n output enable to pin (follows p0.n numbering scheme)? 103, 105, 107, 109, 111, 113, 115, 117 capture p7.n input from pin (follows p0.n numbering scheme)? update p7.n output to pin (fo llows p0.n numbering scheme)? ? not connected to pins in this device package. table 26.2. boundary data register bit de finitions (c8051f061/3/5/7) (continued) extest provides access to both capture and updat e actions, while sample only performs a capture. bit action target figure 26.2. deviceid: jtag device id register version = 0000b part number = 0000 0000 0000 0110b (c8051f060/1/2/3/4/5/6/7) manufacturer id = 0010 0100 001 b (silicon labs) reset value version part number manufacturer id 1 0xn0006243 bit31 bit28 bit27 bit12 bit11 bit1 bit0
c8051f060/1/2/3/4/5/6/7 322 rev. 1.2 26.2. flash programming commands the flash memory can be programmed directly over the jtag interface using the flash control, flash data, flash address, and flash scale registers. thes e indirect data registers are accessed via the jtag instruction register. read and write operations on indi rect data registers are performed by first setting the appropriate dr address in the ir register. each read or write is then initiated by writing the appropriate indirect operation code (indopcode) to the selected data register. incoming commands to this register have the following format: indopcode: these bit set the operation to perform according to the following table: the poll operation is used to check the busy bit as described below. although a capture-dr is performed, no update-dr is allowed for the poll operation. since updates are disabled, polling can be accomplished by shifting in/out a single bit. the read operation initiates a read from the register addressed by the draddress. reads can be initiated by shifting only 2 bits into the indirect register. afte r the read operation is initia ted, polling of the busy bit must be performed to determine when the operation is complete. the write operation initiates a write of writedata to the register addres sed by draddress. registers of any width up to 18 bits can be written. if the register to be written contains fewer than 18 bits, the data in write- data should be left-justified, i.e. its msb should occupy bit 17 above. this allows shorter registers to be written in fewer jtag clock cycles. for example, an 8-bi t register could be written by shifting only 10 bits. after a write is initiated, the busy bit should be polled to determine when the next operation can be initi- ated. the contents of the instruction re gister should not be altered while either a read or write operation is busy. outgoing data from the indirect data register has the following format: the busy bit indicates that the current operation is not complete. it goes high when an operation is initiated and returns low when complete. read and write commands are ignored while busy is high. in fact, if poll- ing for busy to be low will be followe d by another read or wr ite operation, jtag writes of the next operation can be made while checking for busy to be low. they will be ignored unt il busy is read low, at which time the new operation will initiate. this bit is placed at bi t 0 to allow polling by single-bit shifts. when waiting for a read to complete and busy is 0, the following 18 bits can be shifted out to obtain the resulting data. readdata is always right-justified. this allows regi sters shorter than 18 bits to be read using a reduced number of shifts. for example, the results from a byte-read requires 9 bit shifts (busy + 8 bits). 19:18 17:0 indopcode writedata indopcode operation 0x poll 10 read 11 write 19 18:1 0 0 readdata busy
c8051f060/1/2/3/4/5/6/7 rev. 1.2 323 figure 26.3. flashcon: jtag flash control register this register determines how th e flash interface logic will respond to reads and writes to the flashdat register. bit7: sfle: scratchpad flash memory access enable when this bit is set, flash reads and writes through the jtag port are directed to the 128- byte scratchpad flash sector. when sfle is set to logic 1, flash accesses out of the address range 0x 00-0x7f should not be atte mpted. reads/writes out of this range will yield undefined results. 0: flash access from jtag directed to the program/data flash sector. 1: flash access from jtag directed to the scratchpad sector. bits6-4: wrmd2-0: write mode select bits. the write mode select bits control how the interface logic responds to writes to the flash- dat register per the following values: 000: a flashdat write replaces the data in the flashdat register, but is otherwise ignored. 001: a flashdat write initiates a write of flashdat into the memory address by the flashadr register. flashadr is incr emented by one when complete. 010: a flashdat write initiates an erasure (sets all bytes to 0xff) of the flash page containing the address in flashadr. the data wr itten must be 0xa5 for the erase to occur. flashadr is not affected. if flashadr = 0x7bfe - 0x7bff, the entire user space will be erased (i.e. entire flash memory except for reserved area 0x7c00 - 0x7fff). (all other values for wrmd2-0 are reserved.) bits3-0: rdmd3-0: read mode select bits. the read mode select bits control how the in terface logic responds to reads to the flash- dat register per the following values: 0000: a flashdat read provides the data in the flashdat register, but is otherwise ignored. 0001: a flashdat read initiates a read of the byte addressed by the flashadr register if no operation is currently active. this mode is used for block reads. 0010: a flashdat read initiates a read of the byte addressed by flashadr only if no operation is active and any data from a previous read has already been read from flash- dat. this mode allows si ngle bytes to be read (or the last by te of a block) without initiating an extra read. (all other values for rdmd3-0 are reserved.) reset value sfle wrmd2 wrmd1 wrmd0 rdmd3 rdmd2 rdmd1 rdmd0 00000000 bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
c8051f060/1/2/3/4/5/6/7 324 rev. 1.2 figure 26.4. flashdat: jtag flash data register this register is used to read or write data to the flash memory across the jtag interface. bits9-2: data7-0: flash data byte. bit1: fail: flash fail bit. 0: previous flash memory operation was successful. 1: previous flash memory operation failed. us ually indicates the asso ciated memory loca- tion was locked. bit0: busy: flash busy bit. 0: flash interface logic is not busy. 1: flash interface logic is pr ocessing a request. reads or wr ites while busy = 1 will not ini- tiate another operation reset value 0000000000 bit9 bit0 figure 26.5. flashadr: jtag flash address register this register holds the address for all jtag flash re ad, write, and erase operations. this register auto- increments after each read or write, regardless of whether the operation succeeded or failed. bits15-0: flash operation 16-bit address. reset value 0x0000 bit15 bit0
c8051f060/1/2/3/4/5/6/7 rev. 1.2 325 26.3. debug support each mcu has on-chip jtag and debug logic that prov ides non-intrusive, full speed, in-circuit debug sup- port using the prod uction part installed in the end application, via the four pin jtag i/f. silicon labs' debug system supports inspection and modification of memory and registers, breakpoints, and single stepping. no additional target ram, program memory, or communi cations channels are required. all the digital and analog peripherals are functional and work correctly (remain synchr onized) while debugging. the watch- dog timer (wdt) is disabled when the mcu is halted during single stepping or at a breakpoint. the c8051f060dk is a development kit with all the hardware and software necessary to develop applica- tion code and perform in-circuit debug with each mcu in the c8051f06x family. each kit includes develop- ment software for the pc, a serial adapter (for c onnection to jtag) and a targ et application board with a c8051f060 installed. serial cables and wall-mount power supply are also included.
c8051f060/1/2/3/4/5/6/7 326 rev. 1.2
c8051f060/1/2/3/4/5/6/7 rev. 1.2 327 document change list revision 1.1 to revision 1.2 ? added four part numbers: c8051f064, c8051f065, c8051f066, and c8051f067. ? modified all sections to describe functionality of the four new parts. ? revised and expanded flash chapter with cleare r descriptions of flash security features. ? uart0 chapter, section 22.3: ?fe0 in register scon0? changed to ?fe0 in register ssta0?. ? uart0 chapter: updated and clarified baud rate equations. ? port i/o chapter, section 18.2: added a note in text body that port 4-7 registers are all on sfr page f. ? comparators chapter: updated table 12.1 ?comparator electrical characteristics?. ? cip51 chapter: section 13.4.1: added note regarding idle mode operation. ? adc2 chapter: ad2ljst bit remove d from adc2cf register descript ion (ad2ljst is in the adc2cn register). ? adc2 chapter: updated table 7.1 ?adc2 electrical characteristics? and figure 7.2 ?temperature sen- sor transfer function? with temperature sensor information. ? adc0/adc1 chapter: tracking/conversion timing when adntm = 1 is shown in figure 5.4 and table 5.1. references to ?18? or ?16? sar clocks of tracking were removed. ? dacs chapter, table 8.1 ?dac electrical characteri stics?: changed ?gain error? to ?full-scale error?. ? smbus chapter, figure 20.9 smb0cr: changed ?1.125? to ?1.125 * 10^6?. ? pca chapter, figure 25.12 pca0cpmn: bit 0 name changed to ?eccfn? (from incorrect ?eecfn?). ? jtag chapter, figure 26.3 flashcon: bit 7 description corrected. bit 7 is sfle, allowing access to the scratchpad memory area. ? can chapter: added text ?the can controller?s clock (f sys , or can_clk in the c_can user?s guide) is equal to the cip-51 mcu?s clock (sysclk).? ? table 4.1 ?pin descriptions?, mo nen: added text ?recommended conf iguration is to connect directly to vdd.? ? timers chapter: all refere nces to ?dcen? and ?decen? corrected to ?dcenn?. ? timers chapter, equation 24.1: equation was correc ted to ?fsq = ftclk / (2*(65536-rcapn))?. this equation is valid for a timer counting up or down. ? timers chapter, figure 24.14 tmrncf: corrected bit 1 description. for square-wave output, cp/rln = 0, c/tn = 0, tnoe = 1. ? vref chapters: added vref powe r supply current to vref electrical characteristics tables. ? pca chapter: added note about writing pca0cpln and pca0cphn to sections for sw timer mode, high-speed output mode, frequency output mode, 8-bit pwm mode, and 16-bit pwm mode. ? oscillators chapter, table 15 .1 ?internal oscillator el ectrical characteristics?: updated typical supply current. ? table 3.1 ?global dc electrical characteristics?, updated supply current numbers with additional char- acterization data. ? adc0/adc1 chapter: table 5.2 ?adc0 and adc1 elec trical characteristics?, updated supply current numbers with additional characterization data. ? adc0/adc1 chapter: table 5.3 ?voltage reference 0 and 1 electrical charac teristics?, updated out- put voltage numbers with characterization data. ? figure 4.3 ?tqfp-100 package drawing?, added ?l? dimension. ? figure 4.6 ?tqfp-64 package drawing?, added ?l? dimension.
c8051f060/1/2/3/4/5/6/7 328 rev. 1.2 contact information silicon laboratories inc. 4635 boston lane austin, tx 78735 tel: 1+(512) 416-8500 fax: 1+(512) 416-9669 toll free: 1+(877) 444-3032 email: productinfo@silabs.com internet: www.silabs.com silicon laboratories and silicon labs are trademarks of silicon laboratories inc. other products or brandnames mentioned herein are trademark s or registered trademarks of their respective holders the information in this document is believed to be accurate in al l respects at the time of publ ication but is subject to change without notice. silicon laboratories assumes no responsibility for erro rs and omissions, and disclaims responsibility for any consequen ces resulting from the use of information included herein. additi onally, silicon laboratories assumes no responsibility for the fun ction- ing of undescribed features or parameters. silicon laboratories re serves the right to make change s without further notice. sili con laboratories makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpos e, nor does silicon laboratories assume any liabi lity arising out of the application or use of any product or circuit, and specifi cally disclaims any and all liability, including without limitation consequential or incidental damages. silicon laboratories product s are not designed, intended, or authorized for use in applications in tended to support or sustain life, or for any other application in which the failure of the silicon laboratories product could create a si tuation where personal injury or death may occur. should buyer purchase or use silicon laboratories products for any such unintended or unauthorized application, buyer shall indemnify and hold silicon laboratories harmless against all claims and damages.


▲Up To Search▲   

 
Price & Availability of C8051F06007

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X